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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top