Visual Basic 6 <--> Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adrian Parker

    Visual Basic 6 <--> Access

    I'm reading/writing from Access using both EXECUTE() and Recordset methods.

    I get weird errors though. For example I have 5 text boxes bound to fields.
    I will change the data in a couple of the text boxes then immediately try to
    do a INSERT to add another record. This returns errors like, "operation not
    allowed in this context".

    Is it possible to force the database to check the value of bound fields, and
    immediately write them to the datasource fields in the database?


    Adrian


  • Adrian Parker

    #2
    Re: Visual Basic 6 &lt;--&gt; Access


    "Adrian Parker" <adrian.parker@ NOSPAMsympatico .ca> wrote in message
    news:EB90c.2034 0$Mo4.756539@ne ws20.bellglobal .com...[color=blue]
    > I'm reading/writing from Access using both EXECUTE() and Recordset[/color]
    methods.[color=blue]
    >
    > I get weird errors though. For example I have 5 text boxes bound to[/color]
    fields.[color=blue]
    > I will change the data in a couple of the text boxes then immediately try[/color]
    to[color=blue]
    > do a INSERT to add another record. This returns errors like, "operation[/color]
    not[color=blue]
    > allowed in this context".
    >
    > Is it possible to force the database to check the value of bound fields,[/color]
    and[color=blue]
    > immediately write them to the datasource fields in the database?[/color]

    Particularly, if I change any of the values of a bound field, then run any
    of the following without first using an adorecordset move (movenext, last,
    etc), an error occurs:

    ..requery
    ..save
    ..close

    etc



    Adrian


    Comment

    • Steve Gerrard

      #3
      Re: Visual Basic 6 &lt;--&gt; Access


      "Adrian Parker" <adrian.parker@ NOSPAMsympatico .ca> wrote in message
      news:wT90c.2034 5$Mo4.757921@ne ws20.bellglobal .com...[color=blue]
      >
      > "Adrian Parker" <adrian.parker@ NOSPAMsympatico .ca> wrote in message
      > news:EB90c.2034 0$Mo4.756539@ne ws20.bellglobal .com...[color=green]
      > > I will change the data in a couple of the text boxes then[/color][/color]
      immediately try[color=blue]
      > to[color=green]
      > > do a INSERT to add another record. This returns errors like,[/color][/color]
      "operation[color=blue]
      > not[color=green]
      > > allowed in this context".
      > >
      > > Is it possible to force the database to check the value of bound[/color][/color]
      fields,[color=blue]
      > and[color=green]
      > > immediately write them to the datasource fields in the database?[/color]
      >
      > Particularly, if I change any of the values of a bound field, then run[/color]
      any[color=blue]
      > of the following without first using an adorecordset move (movenext,[/color]
      last,[color=blue]
      > etc), an error occurs:
      >
      > .requery
      > .save
      > .close
      >[/color]

      As soon as one field of a recordset is edited, the recordset enters the
      "Edited" state. When you move next, ADO performs an implicit "Update" on
      the recordset. As you have noticed, it does not do that before Requery,
      etc.

      Basically you just need to check for the edited state, and perform
      Update before doing other tasks. So, use something like:
      If RS.EditMode <> adEditNone Then
      RS.Update
      End If
      RS.Requery


      Comment

      Working...