Dlookup Problems...

  • Thread starter Thread starter Jason Buck
  • Start date Start date
J

Jason Buck

W/Access 2003

My code looks like:

grgrName = DLookup("GRGR_NM", "Set Up", "GRGR_ID = " +
Me.GRGR_ID)

I keep on geting a error, data type mismatch in criteria.
The filed in the Set Up Table GRGR_ID is Text data type.
The spelling is righ and the columns I am wanting are in
the Set Up table. I am not sure what else to check. I
don't know what I am doing worng..

Any Ideas?? Thanks in advance.
 
Try:

grgrName = DLookup("GRGR_NM", "Set Up", _
"GRGR_ID = " & Chr$(34) & Me.GRGR_ID & Chr$(34) )
 
grgrName = DLookup("GRGR_NM", "Set Up", "GRGR_ID = " +
Me.GRGR_ID)

In addition to Van's advice, I think the illegal space in the table name
needs to be protected as well:

DLookup("GRGR_NM", "[Set Up]", _
"GRGR_ID = """ & Me.GRGR_ID & """" )

Hope that helps


Tim F
 
Thanks, Tim

Copied and pasted a bit too quickly ...

--
HTH
Van T. Dinh
MVP (Access)



Tim Ferguson said:
grgrName = DLookup("GRGR_NM", "Set Up", "GRGR_ID = " +
Me.GRGR_ID)

In addition to Van's advice, I think the illegal space in the table name
needs to be protected as well:

DLookup("GRGR_NM", "[Set Up]", _
"GRGR_ID = """ & Me.GRGR_ID & """" )

Hope that helps


Tim F
 
I think your code should look like this:

grgrName = DLookup("[GRGR_NM]", "Set Up", "GRGR_ID = " +
Me.GRGR_ID)
 
I think your code should look like this:

grgrName = DLookup("[GRGR_NM]", "Set Up", "GRGR_ID = " +
Me.GRGR_ID)

No: the fieldname is about the only legal and valid bit of this statement!

ATB


Tim F
 
Back
Top