View Full Version : how to ‘goto’ a record?


arage
01-05-2001, 10:24 AM
Hi,
On my user form I have a text box which contains a reference #. I’d like the user to be able to enter a different reference # in another field and then ‘goto’ the requested record (ie the record w/the matching reference # entered)

I’d appreciate any help as I haven’t attempted anything like this before.

ntp
01-07-2001, 11:05 AM
I'm assuming your form is based on some table or query. You can create a command button so th euser can click on it once a reference # has been entered. Ad the following code to the command button's OnClick event.

Private Sub cmdGoTo_Click()
Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[ReferenceNumber] = " & Me.txtReferenceNumber
If rst.NoMatch Then
MsgBox "Error: no entry with reference found."
Else
Me.Bookmark = rst.Bookmark
End If
End Sub

This will change the bookmark of the form to the found record then cause the form to display the selectede record.