Populating text box based on selection in two combo boxes

S

SHAWTY721

I have a form that contains two combo boxes that are related to each other. I
need to find a way to populate my text box based on the criteria of the two
combo boxes so the appropriate number appears in the text box. I created a
DLookup Function that works when I run it using Query designer but when I add
it to the Control Source of my text box it returns nothing. I'm not sure if
this is because the second combo box values are based on the selection made
from the first comb box.
 
J

John W. Vinson

I have a form that contains two combo boxes that are related to each other. I
need to find a way to populate my text box based on the criteria of the two
combo boxes so the appropriate number appears in the text box. I created a
DLookup Function that works when I run it using Query designer but when I add
it to the Control Source of my text box it returns nothing. I'm not sure if
this is because the second combo box values are based on the selection made
from the first comb box.

Correct the error in your code or your query.

If you'ld like help doing so, please post the code and/or the SQL view of the
query. We can't see it from here.

John W. Vinson [MVP]
 
S

SHAWTY721

Here is the DLookup I'm trying to use that works in the query designer but
not when I use it as the Control Source for the text field

=DLookUp("[BranchNumber]","[tblAllADPCoCodes]","[ADPCompany]= '" &
[cboADPCompany] & "' And [LocationNumber]= '" & [cboLocationNo] & "'")
I have a form that contains two combo boxes that are related to each other. I
need to find a way to populate my text box based on the criteria of the two
[quoted text clipped - 3 lines]
this is because the second combo box values are based on the selection made
from the first comb box.

Correct the error in your code or your query.

If you'ld like help doing so, please post the code and/or the SQL view of the
query. We can't see it from here.

John W. Vinson [MVP]
 
J

John W. Vinson

Here is the DLookup I'm trying to use that works in the query designer but
not when I use it as the Control Source for the text field

=DLookUp("[BranchNumber]","[tblAllADPCoCodes]","[ADPCompany]= '" &
[cboADPCompany] & "' And [LocationNumber]= '" & [cboLocationNo] & "'")

What's actually in the fields ADPCompany and LocationNumber? Are they Text
fields, or perhaps numeric ID's concealed by Lookup Fields? Do the values in
the fields match the values in the bound column of the combo boxes? Do you
need to Requery this control in the AfterUpdate events of the combos?

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top