View Single Post
  #7 (permalink)  
Old February 3rd, 2012, 09:07 PM
STEFFANI STEFFANI is offline
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default One more thing

Greg, thank you that code worked perfectly, although I am not the original poster I have been trying to make this work in my database and now it does.

I only have one big issue.
I have a combobox for the "customers" last name, when selected it autofills the rest of the information about the customer into other fields on the same form. My issue is the database was set up on a fly and the primary key is "order number" so the customers name is listed multiple times. When the user selects the combobox there are hundreds of smiths. Do I have to make a new form with a subform so it's done right or can I just add a new field to somehow limit the customer information to one record? The thought of having to redo the relationships throughout the entire database is killing me.

Thanks
Steffani

Quote:
Originally Posted by SerranoG View Post
Hi, David. Welcome to P2P. Here are two ways to tackle this.

1) Mike is correct that you can populate the combobox with field1 and field2 from the table. You can hide the second column of the combobox (or not). In the combobox's AfterUpdate event, you'd have.

Me.TextBox = Me.ComboBox.Column(1)

This assumes the first column (i.e. Column(0)) has the visible dropdown values, and the second column (i.e. Column(1)) has the desired values.

2) If you have only one column in the dropdown, then you can get the same effect this way.

Me.TextBox = DLookUp("[Field2]", "MyTable", "[Field1] = '" & Me.ComboBox & "'")

I'm using fake names for everything. Substitute your real ones.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote