0

screenshot of my error message

I'm trying to create a plant database using MS-Access 2010. I'm trying to open a form by clicking on a button. From what I've researched online, I realize the problem lies with the single quotes, but I don't understand coding enough to figure our what I'm supposed to do to bypass the issue.

Here is the code I'm using.

="[Latin Name]=" & "'" & [Latin Name] & "'"

Andre
  • 26,751
  • 7
  • 36
  • 80

1 Answers1

0

The last part of the Latin name ("cultivar" says a dictionary) usually is enclosed in single quotes itself. So you cannot simply concatenate the name into a query expression where it is separated by single quotes.

If you have ever heard of SQL injection, that's what is happening here.

You need to escape the single quotes with the Replace() function:

="[Latin Name]=" & "'" & Replace([Latin Name], "'", "''") & "'"
Andre
  • 26,751
  • 7
  • 36
  • 80