Hi all,
There are some situations where we need to take a control value as parameter for searching.
Consider this example:
------------------------------------------------------------------------------
Mytarget = "[MyField] = ' " & MyTextBox & " ' "
If IsNull(DLookup("[MyField]", "MyTable", Mytarget)) Then
'do something
End If
------------------------------------------------------------------------------
The problem is whenever the control itself (in this case 'MyTextBox') contains a single quote, Access will generate a run-time syntax error. (Double quotes also have the same problem if that's how you represent string value)
I am having the same problem when trying to include a control value in SQL statements. Does anyone know how to solve this?
Any advises would be highly appreciated.
Thanks,
Bello
There are some situations where we need to take a control value as parameter for searching.
Consider this example:
------------------------------------------------------------------------------
Mytarget = "[MyField] = ' " & MyTextBox & " ' "
If IsNull(DLookup("[MyField]", "MyTable", Mytarget)) Then
'do something
End If
------------------------------------------------------------------------------
The problem is whenever the control itself (in this case 'MyTextBox') contains a single quote, Access will generate a run-time syntax error. (Double quotes also have the same problem if that's how you represent string value)
I am having the same problem when trying to include a control value in SQL statements. Does anyone know how to solve this?
Any advises would be highly appreciated.
Thanks,
Bello