How can I select a record from a list box in VBA.
You are not giving much detail, so I will make some assumptions:
You have a form based on a table or a query.
On the form is an _unbound_ listbox -- its rowsource duplicates the table
or query and it displays all the PK values.
Now, you can use the AfterUpdate event of the listbox to do one of the
following:
Call the DoCmd.GoToRecord method to reposition the form on the
required record
Use the Bookmark property of the Form to reposition the form on
the required record
Set up a new SQL string and set the form's Recordsource to it,
so as to give the user access to only the one record
The last one requres more programming than the other two, but it has the
advantage that the user does not move accidentally on to the next or
previous records by PgUp or Tab etc. Check on help, including the
examples, for details of the first two.
Hope that gives you a start...
B Wishes
Tim F