Dlookup

T

Tom

HI there

I am using the dlook up function, and its working fine
till i dont use the criteria, once i put in the criteria
it dosent work.
Following is the code which is not working

Dim varX As Variant
varX = DLookup("[F_Flag]", "Flag Support", "[P_Name]=" &
Forms![output calculation]!P_Name)

If i remove the criteria itw working fine.

I would appreciate if someone would help me on this.

Thank you.
 
R

Rick Brandt

Tom said:
HI there

I am using the dlook up function, and its working fine
till i dont use the criteria, once i put in the criteria
it dosent work.
Following is the code which is not working

Dim varX As Variant
varX = DLookup("[F_Flag]", "Flag Support", "[P_Name]=" &
Forms![output calculation]!P_Name)

If i remove the criteria itw working fine.

If Len(Nz(Forms![output calculation]!P_Name,""))= 0 Then
varX = DLookup("[F_Flag]", "Flag Support")
Else
varX = DLookup("[F_Flag]", "Flag Support", "[P_Name]='" & Forms![output
calculation]!P_Name & "'")
End If
 
S

Shaun Beane

Tom, note the extra set of quotes Rick added to the criteria - that "may" be
your only problem. If the [P_Name] field is text, you need to wrap the
criteria in quotes.

--
Shaun Beane, MCT, MCDBA
http://dbageek.blogspot.com
Dim varX As Variant
varX = DLookup("[F_Flag]", "Flag Support", "[P_Name]=" &
Forms![output calculation]!P_Name)

If i remove the criteria itw working fine.

If Len(Nz(Forms![output calculation]!P_Name,""))= 0 Then
varX = DLookup("[F_Flag]", "Flag Support")
Else
varX = DLookup("[F_Flag]", "Flag Support", "[P_Name]='" & Forms![output
calculation]!P_Name & "'")
End If
 

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 Challenge 11
DLOOKUP coding issue 13
dlookup compare date values 8
defining label 1
dlookup 2
DLookup error 1
need help writing a DLookup statement 7
last piece missing in combo box look up 1

Top