in message
OK now I have my list box fully populated.
Now I want to be able to select a record from the ListBox and open a form
up based on that record.
I have it where I doubleclick on the row and it opens the form.
But my question is how do I bring over the selected record?
Presumably you have either a macro or a VBA event procedure triggered by
the list box's DblClick event. If it's a macro, it probably executes the
OpenForm action; if a VBA event procedure, it probably calls the
DoCmd.OpenForm method. Either way, it passes an argument that tells what
form to open. The OpenForm action or method also accepts a WhereCondition
argument, and you can use it to specify a criterion for the record to be
displayed by the form.
I'll assume for the sake of argument that you have a VBA event procedure,
and that it includes a line of code something like this:
DoCmd.OpenForm "YourFormName"
You need to change that to specify a criterion that will select the
specific record that was double-clicked in the list box. The code might
look something like this:
DoCmd.OpenForm "YourFormName", _
WhereCondition:="[YourIDField]=" & Me.lstYourListbox
You should replace "YourFormName" with the name of the form to be opened,
"YourIDField" with the name of the primary key field of the table on which
that form is based, and "lstYourListbox" with the name of the list box.
Note: the above assumes that [YourIDField] is a numeric field. If it's a
text field, you need to wrap quotes around the value you pick up from the
list box, so that it looks something like this:
DoCmd.OpenForm "YourFormName", _
WhereCondition:="[YourIDField]='" & Me.lstYourListbox & "'"
The above assumes that the single-quote character (') won't appear in the
key field; if it does, other modifications must be made.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)