Yarik
Yep! Looks like this is one of these long-running discussions. Hope you're
still watching this one.
As far as I can tell from some research, this won't do exactly what you
want. Unfortunately, this is seems due to the way Access uses the Value,
OldValue fields on its forms. The underlying recordset object has another
one for each field - called OriginalValue. The recordset uses all three
value to determine if the value has been changed and needs to be updated back
to the database. Because of the way Access forms work, by the time you get
to the AfterUpdate event of the form, the OriginalValue property is altered
and all thee value properties for the recordset field are the same. With no
differences to detect, the updatebatch method (when eventually called)
doesn't update the record - it thinks it's been done already. The method can
only ever update the current record at teh time it is called. Run some
Debug.Print sequences against your recordset in the form events and you'll
see what I mean.
I haven't tried it in Access 2K7 yet, but I don't think it will be any
different as far as the mdb format is concerned. The newer XML-based format
might do it, but I wouldn't hold out much hope. I think the problem is
inherent in the way the forms are constructed on screen and then attached to
the underlying recordset. It's simpler than VB, but not as flexible.
HTH
"Yarik" wrote:
>
> Keithr wrote:
> > Yarik
>
> I apologize for a long delay with response, but I really thought the
> discussion thread was dead soon after 12/12/06. I did not expect any
> more responses, so I did not visit the thread for quite some
> time...(When the heck is Google going to enable thread posting
> notifications? Almost all other online forums can do that...)
>
> > Try this one:
> >
> > Option Compare Database
> > Option Explicit
> >
> > Dim rs As ADODB.Recordset, cnn As ADODB.Connection
> > Dim strSQL As String
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > cnn.Open
> > Set rs.ActiveConnection = cnn
> > rs.Update
> > Set rs.ActiveConnection = Nothing
> > cnn.Close
> > End Sub
> >
> > Private Sub Form_Open(Cancel As Integer)
> > Set cnn = CreateObject("ADODB.Connection")
> > cnn.ConnectionString = CurrentProject.BaseConnectionString 'or other as
> > required
> > cnn.CursorLocation = adUseClient
> > cnn.Open
> > strSQL = "Select * From [Product]"
> > Set rs = CreateObject("ADODB.Recordset")
> > rs.CursorLocation = adUseClient
> > rs.Open strSQL, cnn, adOpenStatic, adLockOptimistic
> > Set rs.ActiveConnection = Nothing
> > cnn.Close
> > Set Me.Recordset = rs
> > End Sub
> >
> > It isn't perfect, but it avoids user's going to lunch and tying up server
> > resources with long-term connections (especially if they start and edit and
> > forget about it while they have an extended phone call!). It retains the
> > conflict resolution, if your surmise is right, but only connects when
> > necessary and for as long as necessary. Not quite as good as a batch update,
> > I agree, but an improvement over permanent binding in some situations.
>
> Hmm... I don't think this code does what I wanted. Once a user leaves a
> changed record (e.g. by moving to another record) this code would
> update the changed record immediately, right? But the whole point was
> to defer actual updates until user changes multiple records and
> indicates that he/she now wants all the changes to become persistent.
>
> What I was trying to do is to use a disconnected recordset to implement
> something that could be called "user-interface-level transaction" (not
> to be confused with a database-level transaction).
>
> Thank you, Keithr, for your response anyway.
>
>
|