Using a list box to go to a specific record

  • Thread starter Thread starter Convoy
  • Start date Start date
C

Convoy

Hi. I have a database with tblClients that has a list of
clients, each with a unique clientID (autonumber),
lastName, firstName, Dateofbirth. The user currently
searches for a client by last name by typing the last name
into a textbox on the opening form. If there is one client
with that last name the user is taken to a form
frmConfirmClient to confirm that is the client he/she
wishes to view. If there are 2 clients with the same last
name, I have designed it so that an unbound form is opened
with an unbound listbox that displays the multiple clients
with that last name. I would like the user to be able to
click on the client He/She wants in the listbox and be
taken to the frmConfirmClient with the selected client
info shown (based on the clientID). Any help with this is
greatly appreciated. Thanks.
 
Your listbox needs to be designed so that its value is ClientID. You can easily
do this by basing the listbox rowsource on a query with the following fields:
ClientID
[LastName] & ", " & [FirstName]
DateOfBirth

Then make the bound column property 1, column count 2 and column width 0;1.5

Finally put the following code in the AfterUpdate event of the listbox:

DoCmd.OpenForm "frmConfirmClient",,"[ClientID] = " & Me!NameOfYourListBox
 
Back
Top