Using a list box to go to a specific record

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.
 
P

PC Datasheet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top