Form returns to first record after requery

  • Thread starter Thread starter Jeff via AccessMonster.com
  • Start date Start date
J

Jeff via AccessMonster.com

I tried running the following code as suggested in this form but I get a
object or method not supported message. I can't seem to get the the form to
return to the record it was last on before the requery. When I requery it
returns to the first record.

Dim varID As Variant
If Me.Dirty Then
Me.Dirty = False
End If
varID = Me.ID
Me.Requery

'Find the record again
With Me.RecordsetClone
If IsNull(varID) Then
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
End If
Else
.FindFirst "ID = " & varID
If .NoMatch Then
MsgBox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End If
End With
 
Now this is strange.
I tried:

Dim IDCheck As Long
IDCheck = Me.[ID]
Me.Requery
With Me.RecordsetClone
.Find "[ID]=" & IDCheck
If Not .EOF Then Me.Bookmark = .Bookmark
End With

But now it only works for certain records (ie. ID less than 400). I'm
really confused now.
 
ADO and DAO doesn't work the same way and ADP, beeing a mix of DAO and ADO,
is like your national Jacko: you don't always know when it's DAO or ADO,
especially when you don't give the full information.

Take a look at:
http://www.trigeminal.com/usenet/usenet022.asp?1033

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/acproRecordset.asp

I'm not sure if things like .NoMatch work in the same way with ADO than with
DAO. Personally, I use something like:

With Me.RecordsetClone
.Find "[IdLigue]=" & Me!ComboIdLigue

If (.BOF Or .EOF) Then
.movefist
If (.BOF Or .EOF) Then Exit Sub
End If

Me.bookmark = .bookmark
End With


For Me.Dirty, it migth be a better idea to use:

If (Me.Dirty or Me.NewRecord) Then
DoCmd.RunCommand acCmdSaveRecord
End If

I don't know what's the use of the Me.Requery command in your case.
 
I run the requery after I save the record to update the form's data. (ie.
if other users make changes). My problem is returning to the record I was
last on. It isn't working for all records.
 
Back
Top