Lets try this again. I am trying to use DLookup to bring up several fields
from a table into a form. Can someone please let me know if this is possible
and tell me how to do this? I am new to expression builder so please be
patient with me and specific as well as where to build.
I would like this "CustomerName" that is a number field in Form called
"Distribution" to bring up these fields from "Historical" table that is
linked by the way. The following fields are for me to verify that I have the
correct customer
number. The fields are all text and are fields of there own in the form.
They are as follows: BusinessName ,MailingAddress1, Mailing
Address2, MailingCity, MailingState, MailingZip, and Phone. I tried this:
=DLookUp("[Distribution]","Historical","[CustomerNumber] = "
&Me.[CustomerNumber])
Let's try this again.
1. What is the Recordsource of the Form? What table? Could you post the SQL?
2. What is the Rowsource of the combo box? Could you post its SQL?
3, and most important: are you trying to *COPY* the CustomerName and other
fields from the combo box's table into the form's (different) table, or are
you just trying to *DISPLAY* them? The latter would be correct, so I'll give
instructions:
Include all the fields that you want to see in the Combo Box's Rowsource.
Guessing in the dark, I'll say that the row source might be
SELECT CustomerNumber, BusinessName, MailingAddress1, MailingAddress2,
MailingCity, MailingState, MailingZip, Phone FROM Historical ORDER BY
BusinessName;
You can set the ColumnWidths property of the combo so that columns you don't
want to see have zero width; only the first nonzero column will be visible
when the combo isn't dropped down. So you might have a ColumnWidths property
like
0";1.25";0";0";1";0.25";0"
so the user can see the BusinessName, City and State when the combo is
dropped, and only the BusinessName when it's not.
To display the other fields' data on the form, have a textbox for (say)
MailingAddress1. Set its Control Source property to
=comboboxname.Column(2)
This will display the third column of the combo (it's zero based) - the
mailingaddress1 field.
If you already have a MailingAddress1 control on the form, bound to a
MailingAddress1 field in your table, and this is a different table than the
one upon which the combo box is based... *you're making a bad mistake* or else
need to explain why you would want to violate relational design principles by
storing the same information redundantly in two different table!