I am doing my first DLookup.  I have a form who's record source is a table called Caller Info.  The form is also called Caller Info and has a combo box field called Customer.  When the user selects a customer from the drop down list, the form needs to reference a short table (called Customer) that establishes the relationship between the Customer and  the customer's corresponding Number_system.  Then it needs to put the Number_system in a text box on the form.  In other words, I need it to automatically fill that field (text box) based on the Customer that the user chooses.  This is the line of code that I currently have in the text box properties Control Source.  

Number_system.Value=DLookup("[Number_system]![Customer]", "[Number_system]="&Customer.Value)

The test box is currently giving me a #Name? error.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The syntax for a DLookup statment is:

DLookup("YourFieldNameAsSeenInTheTable", "YourTableName", "SomeOtherField = " & Me.cboYourCombo)

However, it sounds like  you would be better off with a combo box that selects both fields in its rowsource (You can set the width of the column you don't want to see to zero).

The control source of your textbox would look something like this, including the = sign (no VBA needed):

= cboYourCombo.Column(1)
Also note that column numbers are Zero-based.  So the first column is 0 then 1,2,3 etc.
Get rid of the spaces in form, report, control, field and table names.  Lets go for CallerInfo.  Never give objects such as tables and forms the same name - lets go for tblCallerInfo and frmCallerInfo.  Never give controls and fields the same name - lets go for fldName1 and tbxName1.  Getting the picture?

Normally you prefix the name of a control on a form or a report with a prefix denoting the type of control:  cbo -combobox, tbx - textbox, lbx - listbox, cmd - command button, etc.  The naming can be anything you like an you should try and restrict it to three characters.  Thus in code you always know when you are referring to a control cboDrID versus a field fldDriID.

As to the DLookUp()

=DLookUp("myFld","myTable","myCriterion1 AND myCriterion2 AND etc.")

Just my 2¢.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Can you provide some feedback please?
Thanks, but what was missing in my explanation?  It was your first DLookup.  I told you what was wrong.  Just as soon you kept the points than award a B!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.