Setting Value in a Combo Box

G

GeorgieGirl

I have a form with a combo box. Selecting a facility number from the combo
box list will bring up the record associated with that facility number. I
now need to use a macro to open this form, set a value in a combo box and
have it look up the matching record. I am able to set the value of the combo
box, but cannot get it to retrieve the record. How can I do this?
 
S

Steve Schapel

GeorgieGirl,

How do you go about getting the required record when you select the
facility number from the combobox? FindRecord action? Why can't you do
the same?
 
J

John Webb via AccessMonster.com

Is the record you want to display the first one listed in the combo box?

If so, a very simple solution is to put the following in the form Load
event:

****Code Begins*****

me.YOURLISTBOX.select(0) = True

*****Code Ends******

As long as your 'find' function is assigned to the AfterUpdate event of the
combo box I believe that would work.

Otherwise, you could do as Steve suggests, but I always like to use the
smallest amount of code possible (streamline everything you can), so would
change my 'find' function to accept a parameter and place a call to it in
the form Load event and the combo box AfterUpdate event.

Hope that helps

John Webb
 
G

GeorgieGirl

Thanks for you responses. However, I am not writing code, but used the
Lookup Wizard to set up the combo box with a "find a record based on the
value in the combo box."

I was able to use the WHERE condition of the "Open Form" in a macro to
retrieve the matching record.
 
Top