Requery sorts results on form

AndeanWayne

Registered User.
Local time
Yesterday, 22:41
Joined
Jan 21, 2012
Messages
27
I have a form to enter data into a table. One filed in the table comes from a combo box based on a query. When the other two fields are entered the form is requeried to compare the entry against expected results. My problem is when I do the requery the record I am working on gets resorted and my form shows the highest result rather than the current record. It's sorted based on the key field. Is thaere any way to requery but not sort?
 
Perform your preferred sorting order in the Row Source (i.e. the query) of the Combo Box and it will remain in that order after being requeried.
 
Or just do this. In the code where you requery the form:

Code:
Dim lngID As Long
Dim rst As DAO.Recordset
 
lngID = Me.IDFieldNameHere  [COLOR=darkgreen]' change to actual field name[/COLOR]
 
' Do your requery
Me.Requery
 
Set rst = Me.RecordsetClone
 
rst.FindFirst "[IDFieldNameHere] = " & lngID  [COLOR=darkgreen]' change to actual field name[/COLOR]
 
If Not rst.NoMatch Then
   Me.Bookmark = rst.Bookmark
End If
 
rst.Close
Set rst = Nothing
 

Users who are viewing this thread

Back
Top Bottom