Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Syntax error on this line of code when the text of EquipName has an apostrophe in it

I'm getting a syntax error on this line of code when the text of EquipName has an apostrophe in it like "16' BLACK UTILITY"

Me.txtEquipment = DLookup("[Equip Name]", "Equipment", "[Equip Name] = '" & Forms!frmScheduleWorkOrder!subfrmScheduleEquipment.Form!txtEquipName & "'")
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

One way you can handle this is:

Me.txtEquipment = DLookup("[Equip Name]", "Equipment", "[Equip Name] = " &  chr$(34) &  Forms!frmScheduleWorkOrder!subfrmScheduleEquipment.Form!txtEquipName & chr$(34))

Jim.
ASKER CERTIFIED SOLUTION
Avatar of Daniel Pineault
Daniel Pineault

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

Jim, your solution worked but I just discovered I get the syntax error message when EquipName has " marks in it.
Daniel, I can't get your solution to work at all. I'm sure I'm doing something wrong.
You'll need to use Daniel's approach then of doubling up on the delimiter.

his code should go in  a standard module.

Jim.