RecordsetClone- Problem with quotations

  • Thread starter Thread starter Gregory Anderson
  • Start date Start date
G

Gregory Anderson

Help!!! From my combo box (if I select a title that has a double
Quotation mark.
Example (3x5" square)
I get a Syntax error (missing operator)


Private Sub Text54_AfterUpdate()
Dim R As Recordset
Set R = Me.RecordsetClone
R.FindFirst "[FormTitle] = " & Chr(34) _
& Me![Text54] & Chr(34)
Me.Bookmark = R.Bookmark
Me![Text54] = Null
End Sub
 
Hi Gregory

Inside a string, a quote character can be represented by two adjacent
quotes. So, your FindFirst string could be something like this:

[FormTitle] = "3x5"" square"

One way to do this is using the Replace function and wrap the result in
another set of quotes. You can put all this inside a custom function:

Function Enquote(strText As String) As String
Enquote = """" & Replace(strText, """", """""") & """"
End Function

And use it like this:

R.FindFirst "[FormTitle] = " & Enquote(Me![Text54])
 
Back
Top