list box, move to record selected

G

george

Hi,

On top of my clients form I have a listbox listing all clients. What code do
I need to use in order to move the current client on the form to the client
selected in the listbox?

thanks in advance, george
 
E

Erez Mor

hello george
let's say you want the record to show when the user double-clicks the client
name in the list box:
first, make sure the bound column of the listbox is the clientID field
then use this:
Private Sub lstClients_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "clientID=" & lstClients
If rs.NoMatch = False Then Me.Bookmark = rs.Bookmark
rs.Close
Set rs = Nothing
End Sub

you'll need to set a reference to DAO to use this one.
Good luck,
Erez.
 
Top