By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

Populate EMP_ID control with selection from EMP_NAME control

P: 69
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
SELECT distinct T_EMPLOYEE_2.EMP_NAME , T_EMPLOYEE_2.EMP_ID FROM T_EMPLOYEE_2 ;



Expand|Select|Wrap|Line Numbers
  1. Private Sub Cmd_EmpName_Click()
  2.   Dim rs As Recordset
  3.  
  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
  8.  
=================================================

Rowsource for EMP_ID
SELECT DISTINCT T_EMPLOYEE_2.EMP_ID FROM T_EMPLOYEE_2;



Expand|Select|Wrap|Line Numbers
  1. Private Sub Cmd_EmpID_Click()
  2.  
  3.    Dim rs As Recordset
  4.  
  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
  9.  
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
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,660
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.