Using a listbox to populate data for a bound form

G

Guest

I have a bound form to a member table in my Access 2003 DB. The user needs
to be able to search members by last name and select the desired record to
view/edit. I used an unbound listbox to successfully display the records
returned based on the user search. I used a recordset object in VB code to
get and display the data for the listbox. When a user clicks on a record in
the listbox, I want to the form to automatically go to and display the
selected record.

Am I on the right track here? If so, how can I set the current record on
the form to the selected record in the list box? I could not get GoToRecord
to work.
 
A

Anthos

Yes, you are on the right track,
One way to do what you want, is include the Primary Key for your
underlaying data in the form.
(so that your drop down list has a hidden column with the primary key
being the first value)

On the after Update event try the following code.

Me.Filter = "[PrimaryKeyFieldName]=" & Me.combobox.value
Me.FilterOn = True

Keep in mind that the above code will only work if the primary key is
a number and not string
to use string you need to do the following

Me.Filter = "[PrimaryKeyFieldName='" & me.ComboBox.valu & "'"
Me.FilterON = True

Hope that helps,

Regards
Anthony Moore
IT Excellence
 

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

Similar Threads


Top