Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autolookup on two combo boxes

Status
Not open for further replies.

Newbie456

Technical User
Nov 21, 2005
37
US
Sorry if this answer has been posted already - I haven't been able to find it.

I have a table with Scientific Names and Common Names listed for a variety of animal species. Each is unique. I'd like to create two combo boxes on the form that behave as such:
If Scientific Name is selected in cboSName, the corresponding common name is automatically filled in in cboCName
Likewise:
If Common Name is selected in cboCName, the corresponding scientific name is automatically filled in in cboSName

I haven't before had any fields be filled in automatically, much less in a corresponding relationship like this.

Thanks for your help!
 
You could have two columns in each of the comboboxes and set cboOne as equal to the second column of cboTwo in the After Update event of each combo.
 
Good idea. I have this as my code, but it doesn't seem to do anything. What am I missing?

Private Sub cboCName_AfterUpdate()
cboSName = Forms!frmArchaeoCat!cboCName.Column(1)
End Sub

Private Sub cboSName_AfterUpdate()
cboCName = Forms!frmArchaeoCat!cboSName.Column(1)
End Sub
 
If you typed in this code, check that After Update is set to [Event Procedure]. You may like to try:
[tt]Me.cboSName = Me.cboCName.Column(1)[/tt]
 
Yes, that one worked much better. Also had to set it to the first column (easy mistake).

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top