If anyone knows of a simple macro that can enable my users to open a form from a separate form that contains a combo box...and open it to a specific record on the form based on their selection...please let me know....
I forgot to mention that my combo box lists "last name", "first name", "middle initial", and each comes from it's own field....(if that makes any sense)....I'm not sure if that has anything to do with how the macro should be done.
DoCmd.OpenForm "MainForm", , , "FieldName = Last Name, First Name, Middle Initial" (I'm not sure about this)...
Where do I enter this code...is this under "code builder"? When it asks for "FieldName", what would go in there if I have a combo box that contains separate fields such as last name, First name, middle initial? Do I need to put the commas in the code as you have above. And what is & Me.ControlName?
Last edited by akanick; 10-29-10 at 14:26.
Reason: more detail
Now I know where the code goes. But the way I have my combo box set up, it pulls last name, first name, middle initial from a table (*all in one line). I would like have the combo box pull up my main form by the name that the user selects.
The issue I'm having is that last name, first name, middle initial are separate fields within the main form.
So I don't know how to write the code that would enable the user to select the full name from the combo box and have it pull up the record in form view from my main form because there are three different fields...
For starters, using names would not typically be a good idea; sooner or later you'll have two people with the same name. Most of us would use a numeric key field. To do it like that, this type of thing, presuming the names are in separate columns of the combo row source:
Then you don't have any records that match. One way to check this is to make sure your where clause is correctly structured. If you are in 2007 you can set TempVars, it would be much easier in VBA though.