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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use DLOOKUP with multiple selections 1

Status
Not open for further replies.

Steven547

Technical User
Sep 15, 2004
165
0
0
US
Hey everyone...
I have a form that the user selects from 3 combo boxes. Each box generates specific values in the next (they are dependent upon each other). After all 3 are selected, a text box is populated based on those 3 combo boxes.

How would I populate the txt box based on 3 combos? This is the DLOOKUP I have for one record. The txt box is based off the company, subcompany, and department. All 3 of those equals ONE record in the txtBCCoord box:

txtBCCoord = DLookup("[BCCoord]", "[CFR-Master]", " [Company]=cboCompany")

Would I do an "and" after the [company] = cboCompany? I'm trying that and it's not working. Any thoughts?

Thanks.
 
Sorry, forgot to post the full DLOOKUP:

txtBCCoord = DLookup("[BCCoord]", "[CFR-Master]", " [Company]=Company" And [SubCompany] = SubCompany And [Department] = Department)

I'm getting a DataType Mismatch...
 
How are ya Steven547 . . .

... and this:
Code:
[blue]txtBCCoord = DLookup("[BCCoord]", "[CFR-Master]", "[Company] = '" & Me!Company" And "'[SubCompany] = '" & Me!SubCompany & "'"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks. Trying that and getting a syntax error.

txtBCCoord = DLookup("[BCCoord]", "[CFR-Master]", "[Company] = '" & Me!Company" And "'[SubCompany] = '" & Me!SubCompany & "'"

So the "[Company] = '" & Me!Company" is the same as [company]=cboCompany?
 
Replace:
"[Company] = '" & Me!Company" And

With
"[Company] = '" & Me!Company & "' And
 
So it was missing that ' ? I was just "googling" that right now.
 
Still trying to figure this out. This is what I have:
txtActualTargetPath = DLookup("[Target Data]", "[tblMigration]", " [Company]= '" & me!cboCompany & "' and " [subCompany]="' & me!cboSubcompany & '" and "'[department]='" & me!cboDepartment")

The txtActualPath is based on the the info gathered from the 3 sources: cboCompany, cboSubCompany, and cboDepartment. I keep getting a syntax error or "expression" error and can't figure out why.

text field = target field from the table 'A' where company=cboCompany and subcompany=cboSubCompany and department=cboDepartment.
 
Code:
txtActualTargetPath = DLookup("[Target Data]", "tblMigration", "Company='" & me!cboCompany & "' and subCompany='"& me!cboSubcompany & "' and department='" & me!cboDepartment & "'")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top