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

DLookup Problem With Adding A Variable

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
US
Have the following code in the record source for a field on a report -


=DLookUp("[Question]","Qry_Questions","[QuestionNumber] = [reports]![Rpt_Individual_NonSupervisor_Only].[TestVar]")

example for the varaible above -
[reports]![Rpt_Individual_NonSupervisor_Only].[TestVar] = A1

I keep getting an #error. it is a text field that i assign in the open event (based on what the user enters on another report)

THANKS!
 
That occurs because you are trying to compare two fields to each other. Try this instead:

=DLookUp("[Question]","Qry_Questions","[QuestionNumber] = '" & [reports]![Rpt_Individual_NonSupervisor_Only].[TestVar] & "'")

John
 
Try 'single quotes' around the [TestVar] control:
Code:
=DLookUp("[Question]","Qry_Questions","[QuestionNumber] = [COLOR=red]'" [/color]& [reports]![Rpt_Individual_NonSupervisor_Only].[TestVar][COLOR=red] & "'"[/color])


Hoc nomen meum verum non est.
 
THANKS!
Now i am getting the #Name? error.
When I assign the variable i have the following -

testvar = Forms!Frm_Criteria_Selection.txtQuestionChoices

Do i need quotes around that too?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top