Syntax error using dlookup

H

Hugh self taught

Hi All,

I have the following piece of code

ChkProv = DLookup("[Province_Cde]", "Provinces", "[Province_Cde]= ' " &
Left(Nat_Reg, 2))

which I want to use as part of validating that the 1st 2 left chrs of
Nat_Reg correspond with a record in field Province_Cde

However it gives me the following error when executed

Syntax error in string in query expression '[Province_Cde]='GU'

GU is valid in the record I was trying to add as a test & it exists in the
table Provinces.Province_Cde

Any suggestions on what to try to correct this?

Hugh
 
J

John Spencer

Missing a close quote mark and have a leading space in the third argument
before getting the two characters from Nat_Reg.

ChkProv = DLookup("Province_Cde", "Provinces", "Province_Cde= '" &
Left(Nat_Reg, 2) & "'")



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
M

Marshall Barton

Hugh said:
ChkProv = DLookup("[Province_Cde]", "Provinces", "[Province_Cde]= ' " &
Left(Nat_Reg, 2))

which I want to use as part of validating that the 1st 2 left chrs of
Nat_Reg correspond with a record in field Province_Cde

However it gives me the following error when executed

Syntax error in string in query expression '[Province_Cde]='GU'

GU is valid in the record I was trying to add as a test & it exists in the
table Provinces.Province_Cde

You forgot the closing '

ChkProv = DLookup("[Province_Cde]", "Provinces",
"[Province_Cde]= '" & Left(Nat_Reg, 2) & "' ")
 
H

Hugh self taught

Hi John, Marshall & Daniel

Many thanks for the help. Although my knowledge is growing I'm not
proficient at find my intricate errors yet. Works like a charm now

Hugh

John Spencer said:
Missing a close quote mark and have a leading space in the third argument
before getting the two characters from Nat_Reg.

ChkProv = DLookup("Province_Cde", "Provinces", "Province_Cde= '" &
Left(Nat_Reg, 2) & "'")



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
Hi All,

I have the following piece of code

ChkProv = DLookup("[Province_Cde]", "Provinces", "[Province_Cde]= ' " &
Left(Nat_Reg, 2))

which I want to use as part of validating that the 1st 2 left chrs of
Nat_Reg correspond with a record in field Province_Cde

However it gives me the following error when executed

Syntax error in string in query expression '[Province_Cde]='GU'

GU is valid in the record I was trying to add as a test & it exists in the
table Provinces.Province_Cde

Any suggestions on what to try to correct this?

Hugh
.
 

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


Top