DLookUp, how to write?

radek225

Registered User.
Local time
Today, 15:32
Joined
Apr 4, 2013
Messages
307
I awlays have problem with this


"laczone" and "id_zlecenia_info" are text.

Code:
DLookup("[laczone]", "tblZlecenia", "[Laczone]='" & Forms![frmZlecenieRoboczeMarzena]![ID_Zlecenia] & '" And "[ID_Zlecenia_info]='" & Me.NoweNumerZlecenia & "'")

code doesn't work. I think problem is

Code:
...And "[ID_Zlecenia_info]='" & Me.NoweNumerZlecenia & "'")
 
"laczone" and "id_zlecenia_info" are text.

if that is the case, there is nothing wrong with your code so I suspect it is your data - is one of the form fields empty for example?

If not, please expand on 'code doesn't work' as at the moment it is not something that means anything
 
actually just spotted

...And "[ID_Zlecenia_info]='"
the double quote in red is not required
 
If not, please expand on 'code doesn't work' as at the moment it is not something that means anything

"Compile Error:
Expected: expression"

Code:
Dim czyjest As String


czyjest = DLookup("[laczone]", "tblZlecenia", "[Laczone]='" & Forms![frmZlecenieRoboczeMarzena]![ID_Zlecenia] & [COLOR="Red"]'[/COLOR]" And "[ID_Zlecenia_info]='" &  Me.NoweNumerZlecenia & "'")

If I have a code without this part

Code:
And "[ID_Zlecenia_info]='" & Me.NoweNumerZlecenia & "'"

So code is

Code:
czyjest = DLookup("[laczone]", "tblZlecenia", "[Laczone]='" & Forms![frmZlecenieRoboczeMarzena]![ID_Zlecenia] & "'")

Then everything is ok

I know about Nz function, but there aren't empty fields.
 
the error description is telling you there is something wrong with your code - which I have answered in my second post
 
Ms Access Shows the line as red so something is wrong
Code:
Dim czyjest As String


czyjest = DLookup("[laczone]", "tblZlecenia", "[Laczone]='" & Forms![frmZlecenieRoboczeMarzena]![ID_Zlecenia] & '" And [ID_Zlecenia_info]='" & Me.NoweNumerZlecenia & "'")
 
Last edited:
this

...![ID_Zlecenia] & '" And ...

should be

...![ID_Zlecenia] & "' And ...
 

Users who are viewing this thread

Back
Top Bottom