DLookUp syntax help please

G

Guest

Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry
 
C

Carl Rapson

JWCrosby said:
Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but
it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

It looks like you're missing the closing quotes forthe EmployeeID:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"""And [MonthID] = '" & [Month2] & "'")

It might help to be more consistent on the use of single and double quotes:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = '" & [EmployeeID] &
"'And [MonthID] = '" & [Month2] & "'")

Carl Rapson
 
G

Guest

I was hopeful there for a moment, but it didn't work. Still getting #Error,
but I most certainly appreciate your effort to help me.

Would it be helpful to add that the "Month2" field is a control in the form
page header with this syntax: =DLookUp("[Month]","tblMonths","[SortOrder] = "
& "2") It is working and results in "Feb"

Jerry

Carl Rapson said:
JWCrosby said:
Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but
it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

It looks like you're missing the closing quotes forthe EmployeeID:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"""And [MonthID] = '" & [Month2] & "'")

It might help to be more consistent on the use of single and double quotes:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = '" & [EmployeeID] &
"'And [MonthID] = '" & [Month2] & "'")

Carl Rapson
 
F

fredg

Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

If, as you state, EmployeeID is a Number datatype, your syntax is as
if it were Text datatype.

Try:
=DLookUp("[BC_WCC]","qryBC_Tax_Select","[EmployeeID] = " &
[EmployeeID] & " And [MonthID] = '" & [Month2] & "'")

make sure the name of the control is not the same as any field used in
the above expression.
 
C

Carl Rapson

That does make a difference. I don't think you can refer to a calculated
field value like that. If possible, you should link tblMonths to your query,
so that the month value is available without having to use a second DLookUp.
If you can't put the link in qryBC_Tax_Select directly, you could create
another query linking qryBC_Tax_Select to tblMonths and use that query in
your DLookUp for BC_WCC.

Carl Rapson

JWCrosby said:
I was hopeful there for a moment, but it didn't work. Still getting #Error,
but I most certainly appreciate your effort to help me.

Would it be helpful to add that the "Month2" field is a control in the
form
page header with this syntax: =DLookUp("[Month]","tblMonths","[SortOrder]
= "
& "2") It is working and results in "Feb"

Jerry

Carl Rapson said:
JWCrosby said:
Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID]
&
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic,
but
it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

It looks like you're missing the closing quotes forthe EmployeeID:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"""And [MonthID] = '" & [Month2] & "'")

It might help to be more consistent on the use of single and double
quotes:

=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = '" & [EmployeeID] &
"'And [MonthID] = '" & [Month2] & "'")

Carl Rapson
 
G

Guest

thanks, Fred, that got it to work!

Now, if you happen to come back and read this perhaps you could answer
another question. That DLookUp is pulling the correct number from the query
[BC_WCC] and in the report I want to show it as currency. While I have the
field formatted as currency, it isn't showing it as such.

[BC_WCC] in the query is drawn from a public function, if that helps any.

Any ideas on how to get it to show as currency? (If I don't hear back I'll
post as a separate question.)

Jerry

fredg said:
Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

If, as you state, EmployeeID is a Number datatype, your syntax is as
if it were Text datatype.

Try:
=DLookUp("[BC_WCC]","qryBC_Tax_Select","[EmployeeID] = " &
[EmployeeID] & " And [MonthID] = '" & [Month2] & "'")

make sure the name of the control is not the same as any field used in
the above expression.
 
F

fredg

thanks, Fred, that got it to work!

Now, if you happen to come back and read this perhaps you could answer
another question. That DLookUp is pulling the correct number from the query
[BC_WCC] and in the report I want to show it as currency. While I have the
field formatted as currency, it isn't showing it as such.

[BC_WCC] in the query is drawn from a public function, if that helps any.

Any ideas on how to get it to show as currency? (If I don't hear back I'll
post as a separate question.)

Jerry

fredg said:
Here's what isn't working (get error#):
=DLookUp("BC_WCC","qryBC_Tax_Select","[EmployeeID] = """ & [EmployeeID] &
"And [MonthID] = '" & [Month2] & "'")

EmployeeID is a number.
MonthID in the query is a text field.
Month2 is a control on the form that is text.

I've used single and double quotes, which I know can be problematic, but it
helps me understand the pieces...but I still can't get it right.

Thanks in advance.

Jerry

If, as you state, EmployeeID is a Number datatype, your syntax is as
if it were Text datatype.

Try:
=DLookUp("[BC_WCC]","qryBC_Tax_Select","[EmployeeID] = " &
[EmployeeID] & " And [MonthID] = '" & [Month2] & "'")

make sure the name of the control is not the same as any field used in
the above expression.

=Format(DLookUp("[BC_WCC]","qryBC_Tax_Select","[EmployeeID] = " &
[EmployeeID] & " And [MonthID] = '" & [Month2] & "'"),"Currency")
 

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

Similar Threads

DLookup or Code 2
Dlookup syntax 4
Single vs. double quotes 4
Logged in user & DLookup 3
DlookUp Syntax problem 12
Dlookup and my ignorance 5
Need Help with DSUM syntax 1
dlookup problem 9

Top