problem with alphanumeris parameter

  • Thread starter Thread starter R_Luft
  • Start date Start date
R

R_Luft

Hope someone can help!
Trying to do the following:
x = DLookup(fil, "Tblname","[tblfield]" = "Forms![frmname]!
[frmctrl]") where fil is a string.
When fil is alphabetic, there is no problem with this
code, but if fil begins with numbers (eg-1199PIN) then the
code crashes.
Any one have any idea how to get around this?
TIA
 
That should be

x = DLookup(fil, "Tblname","[tblfield] = '" & Forms![frmname]![frmctrl] &
"'")

Exagerated for clarity,

x = DLookup(fil, "Tblname","[tblfield] = ' " & Forms![frmname]![frmctrl] & "
' ")

If there's a chance that there might be an apostrophe in
Forms![frmname]![frmctrl], try

x = DLookup(fil, "Tblname","[tblfield] = " & Chr$(34) &
Forms![frmname]![frmctrl] & Chr$(34))

or

x = DLookup(fil, "Tblname","[tblfield] = """ & Forms![frmname]![frmctrl] &
"""")

(that's 3 double quotes in a row before the field name, and 4 in a row
afterwards)
 
Back
Top