Update form depending on combo box. (1 Viewer)

CarysW

Complete Access Numpty
Local time
Today, 07:28
Joined
Jun 1, 2009
Messages
213
I am again being a bit dim.....


I have a simple Employee Database that contains a datasheet with names, depts, ext numbers, emails etc; and a form to show each employee + details individually.

On that form I want to put a combo box listing employee names that will make the details on the form jump to which employee I have chosen in the combo box. Sounds simple enough, which is why it's driving me mad.

I have set the Row Source of the combo box to be the name field of the table.

What code do I need to use? :confused:
 

SOS

Registered Lunatic
Local time
Yesterday, 23:28
Joined
Aug 27, 2008
Messages
3,517
Actually, if you go to the header of your form and then click on the button to add a combo box (as long as the wizard is enabled) it should give you the option to find a record based on your selection. Follow that and it sets it up automatically.

I just did that on a test db of mine and it came out with this code:
Code:
   ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[OrderID] = " & Str(Nz(Me![Combo30], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

You would need to change the field name (where I have OrderID and the combo box name to your own. But this goes in the After Update event of the combo box in the VBA window.
 

CarysW

Complete Access Numpty
Local time
Today, 07:28
Joined
Jun 1, 2009
Messages
213
Actually, if you go to the header of your form and then click on the button to add a combo box (as long as the wizard is enabled) it should give you the option to find a record based on your selection. Follow that and it sets it up automatically.

.


Ah ha! There's me trying to be clever! I never use the wizards!
 

CarysW

Complete Access Numpty
Local time
Today, 07:28
Joined
Jun 1, 2009
Messages
213
BINGO! Ruddy wizards! I've just spent 2 hours tearing my hair out!! Haha!
 

Users who are viewing this thread

Top Bottom