String expression problem

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using the following string for a dataview expression;

dv.RowFilter = "Company like '*" & Me.txtCompany.Text & "*' "

The problem comes when txtcompany field contains an apostrophe such as
"O'Neil Associates", and the app crashes. How can I get round this problem
i.e. be able to filter even with an apostrophe?

Thanks

Regards
 
John,
Have you considered:
dv.RowFilter = "Company like '*" & _
Me.txtCompany.Text.Replace("'", "''") & "*' "

That's replace a single quote with two single quotes.

Hope this helps
Jay
 
Back
Top