REFRESH / REQUERYCODE - PLEASE HELP..

  • Thread starter Thread starter clawdogs
  • Start date Start date
C

clawdogs

Hi. I have the following code that works up until Me.Requery. I
can't get the code to go to the specified record after Me.Requery.
Control name is COFID and control source is COFID. Someone please
help.

Private Sub COFID_AfterUpdate()
Dim lngKeyVal As Long

lngKeyVal = Me.COFID

Me.Refresh

'Move back to the original record - this doesn't seem to work...
With Me.RecordsetClone
..FindFirst "[COFID] = " & lngKeyVal

End With

End Sub
 
Hi. I have the following code that works up until Me.Requery. I
can't get the code to go to the specified record after Me.Requery.
Control name is COFID and control source is COFID. Someone please
help.

Private Sub COFID_AfterUpdate()
Dim lngKeyVal As Long

lngKeyVal = Me.COFID

Me.Refresh

'Move back to the original record - this doesn't seem to work...
With Me.RecordsetClone
.FindFirst "[COFID] = " & lngKeyVal

End With

End Sub

You need to sync the form's recordset with its recordset
clone:

With Me.RecordsetClone
.FindFirst "[COFID] = " & lngKeyVal
If Not .NoMatch Then Me.Bookmark = ,Bookmark
End With

Or in this special situation, you can get away with:

Me.Recordset.FindFirst "[COFID] = " & lngKeyVal
 
Thanks. This is what finally worked for me:

Private Sub COFID_AfterUpdate()
Dim lngID As Long

lngID = Me.COFID
Me.Requery

RecordsetClone.FindFirst "COFID=" & lngID
Bookmark = RecordsetClone.Bookmark

'only used the below refresh because the first record's data kept
appearing in the COFID field
Me.Refresh

End Sub


Thanks again!
 
Back
Top