How to open forms where control source contain text with apostrop.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (continuous view) showing a list of records. A command button
is built to allow selection of any records to a separate form showing the
details.

Whenever I click a command button to access the form of any record that has
names containing an apostrophe, it returns "syntax error....missing operator".

If the apostrophe must be retained, how should I enable the links to work?
 
Use double-quotes instead of single quotes as the delimiter within the
string.

Example:
Dim strWhere As String
strWhere = "Surname = """ & [SomeTextbox] & """"
DoCmd.OpenForm "Form2", WhereCondition:=strWhere

As the example shows, you have to double them up within the string, so that
Access/VBA does not think it has reached the end of the string:
"This string has a ""word"" in quotes."
 
Back
Top