Daily (1 Viewer)

calioranged

New member
Local time
Today, 22:33
Joined
Nov 26, 2019
Messages
2
My form features a list box which displays Movies in the database as the user types.

When the user clicks on a given record in the list box, I would like the form to go to this particular record.

It seems that the GoToRecord command could be used to this in the On Click event, but I can't figure out what value should be specified in the offset:

Code:
DoCmd.GoToRecord , , acGoTo, [ the clicked record ]

How do I specify that the offset should be equal to the record which the user just clicked on?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:33
Joined
Oct 29, 2018
Messages
21,358
Hi. Welcome to AWF! Rather than GoToRecord, you might check out the FindFirst method and the Bookmark property. I am not sure if there are equivalent actions in a macro.
 

calioranged

New member
Local time
Today, 22:33
Joined
Nov 26, 2019
Messages
2
Thanks.

For anyone who visits this post in the future and is wondering how to do the same thing, this is the code you want inside the On Click event:

Code:
Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[Enter Primary Key Here]=" & [Enter Name of List Box Here] 
If rs.NoMatch Then
MsgBox "That value doesn't exist"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:33
Joined
Oct 29, 2018
Messages
21,358
Thanks.

For anyone who visits this post in the future and is wondering how to do the same thing, this is the code you want inside the On Click event:

Code:
Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[Enter Primary Key Here]=" & [Enter Name of List Box Here] 
If rs.NoMatch Then
MsgBox "That value doesn't exist"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
Hi. Congratulations! Glad to hear you got it worked out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom