find a record based on the information I select in a combo box in

S

StaceyJ

I need to be able to use a lookup/combo box on an unbound menu form (that I
use as my primary switchboard form) to lookup records in my primary form.
How can I do this?

I have 3 fields from the form I want to lookup records in that I want to
display in the lookup box: Company, First Name, and Last Name.


How can I go about making this work?

Thanks for any advice in advance!
 
T

tina

are you trying to find a record in a *table*, and then display that record
in your primary form which is bound to that table? if so, just set the
RowSource of the combo box control, on the menu form, to the same table or
query that is used as the RecordSource in the primary form.

if that's not what you're trying to do, please explain what your goal is.

hth
 
S

StaceyJ

I was using a query to lookup just the information from the table, which is
the same table that the primary form is based on. However, when I select the
option from the menu, how do I get it to actually open up that specific form
and go to that record?
 
T

tina

from the combobox control's AfterUpdate event procedure, or from the Click
event procedure of a command button on the menu form if you prefer, use the
OpenForm action with a WHERE clause, as

DoCmd.OpenForm "PrimaryFormName", , , _
"PrimaryKeyFieldName = " _
& Me!ComboBoxControlName

replace PrimaryFormName with the correct name of the form you want to open,
of course, and also replace PrimaryKeyFieldName with the correct name of the
primary key field in the table that the form is bound to, and replace
ComboBoxControlName with the correct name of the combo box control on the
menu form. also, make sure that the BoundColumn of the combo box control is
the primary key field of the table used in its' RowSource. the above code
assumes that the table's primary key field is a Number data type; if its'
data type is Text, the correct syntax is

DoCmd.OpenForm "PrimaryFormName", , , _
"PrimaryKeyFieldName = '" _
& Me!ComboBoxControlName & "'"

recommend you read up the OpenForm Method topic in Access Visual Basic Help,
so you'll understand how it works, and how/when to use its' arguments.

hth
 

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