469,592 Members | 1,670 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Populate EMP_ID control with selection from EMP_NAME control

Platform = Windows
Program = Access 2003

Hi there, I am stumpped!!

I am attempting to populate a form control as follows:

I have a form that has 2 drop-down boxes. One retrieves the EMP_ID and the 2nd one retrieves the EMP_NAME and EMP_ID.

When I make a selection from the EMP_ID control, the data in the database appears accordingly. When I make a selection from the EMP_NAME control, the data in the database appears accordingly, as well.

I am attempting to have it so when I make a selection from the EMP_NAME control, the EMP_ID control becomes populated with the EMP_ID that corresponds to the selection that I make using the EMP_NAME control.

RowSource for EMP_NAME

Expand|Select|Wrap|Line Numbers
  1. Private Sub Cmd_EmpName_Click()
  2.   Dim rs As Recordset
  4.   Set rs = Me.Recordset.Clone
  5.   rs.FindFirst "[EMP_NAME] = '" & Combo_EmpName.Value & "' "
  6.   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  7. End Sub

Rowsource for EMP_ID

Expand|Select|Wrap|Line Numbers
  1. Private Sub Cmd_EmpID_Click()
  3.    Dim rs As Recordset
  5.    Set rs = Me.Recordset.Clone
  6.    rs.FindFirst "[EMP_ID] = '" & Combo_EmpID.Value & "'"
  7.    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8. End Sub
When I run them independently of each other, they work just fine, but I need to have the EMP_ID control be populated with the EMP_ID when a selection is made from the EMP_NAME form control and also have the EMP_NAME control populate accordingly when a selection is made from the EMP_ID form control.

I hope I have supplied enough information and have explained it clearly enough for someone to help me.

Can someone please help me with this???

Thank you VERY MUCH for your assistance.
Aug 19 '08 #1
1 1542
32,198 Expert Mod 16PB
This all sounds like an overcomplication. A single ComboBox with both items in it is fully referenceable from code. There is no "valid" reason I can see why you would want to set them up as you have.

Having said that, the way to do it would be to set the value of the "other" ComboBox whenever one has an item selected.

Travel this path and expect problems though.
Aug 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by =?Utf-8?B?U2F0aXNo?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.