Trying to Pass Combo Box Value to DLookup

bconner

Registered User.
Local time
Today, 17:14
Joined
Dec 22, 2008
Messages
183
All,
I am trying to pass the value of a combo box to a DLookup function to grab the Report Description field from a table. I keep gettting and error saying there is a missing operator in query expression (Report Description)



txtRpt_ReportDescription = DLookup("Report Description", "Tbl_Report_Dictionary", "Report Name= '" & Me.cmbRpt_ReportName.Value & "'")
 
Just a guess based on the spaces in the "Report Description" and
"Report Name" fieldnames

Code:
txtRpt_ReportDescription = DLookup("[Report Description]", "Tbl_Report_Dictionary", "[Report Name]= '" & Me.cmbRpt_ReportName.Value & "'")
 
Last edited:
JDraw's on to it but missed one:

txtRpt_ReportDescription = DLookup("[Report Description]", "Tbl_Report_Dictionary", "[Report Name]= '" & Me.cmbRpt_ReportName.Value & "'")


And you wouldn't have that problem if you didn't include spaces in your field or object names.
 
Thanks Bob, was updating my post when you posted.
 
JDraw, thanks for the help, I took your advice and I also added brackets around [Report Name] and that worked. Thanks again..
 
BobLarson, thanks for the tip, I usually don't put spaces in names and certainly won't after this.......
 
Was doing something similar to what bconner had. I've this expression

=DLookUp("Mar","ctbMonthlySegments","[PCC]='0hq'")

I need to change the 0hq to a combobox value that is selected or a list value. How can I achieve that ? ctbMonthlySegments is a crosstab query.
 
more like this (for a number)

=DLookUp("Mar","ctbMonthlySegments","[PCC]=" & ohq

or maybe this (for a string)

=DLookUp("Mar","ctbMonthlySegments","[PCC]=" & chr(34) & ohq & chr(34)
 
Thanks hemma. Yes i need the string expression. What does chr(34) mean ?
 
I've managed to get this expression

=DLookUp("Feb","ctbMonthlySegments","[Forms]![SegmentPCC]![cmbPCC]=""")

but the above gives me an #Error in the field.
 
After some trial and error I've managed to get the expression correct and it is

=DLookUp("Feb","ctbMonthlySegments","[PCC]=" & "'" & [Forms]![SegmentPCC]![cmbPCC] & "'")

The problem that I face next is that this expression does not get updated when using the form in form view.


where did I go wrong ?
 

Users who are viewing this thread

Back
Top Bottom