Problem with apostrophe character in Seclect Query

vadharah

Registered User.
Local time
Today, 22:43
Joined
Oct 14, 2008
Messages
35
i have a select query which is now working fine thanx to your SUPPORT!!

however within my WHERE clause i am comparing with the value "Don't Have" as text the query is:

str = "SELECT student.MainContact, student.Add1, student.Add2 FROM student INNER JOIN gradesON student.studentID = grades.studentID WHERE grades.grade='" & Forms!search!gr.Value & "' AND grades.Usage='" & (Forms!search!Usage.Value) & "'"

i have noticed in the query im also using an apostrophe ' and the value in my textbox happens to be "Don't Own" containing an apostrophe.....all other values are working perfectly but on this value i get an error.....

how can i avoid this?
 
Try this instead:

str = "SELECT student.MainContact, student.Add1, student.Add2 FROM student INNER JOIN gradesON student.studentID = grades.studentID WHERE grades.grade=" & Chr(34) & Forms!search!gr.Value & Chr(34) & " AND grades.Usage=" & Chr(34) & (Forms!search!Usage.Value) & Chr(34)
 
Try this instead:

str = "SELECT student.MainContact, student.Add1, student.Add2 FROM student INNER JOIN gradesON student.studentID = grades.studentID WHERE grades.grade=" & Chr(34) & Forms!search!gr.Value & Chr(34) & " AND grades.Usage=" & Chr(34) & (Forms!search!Usage.Value) & Chr(34)


thank you bob!!....muc appreciated ...im learning new things by the day
 

Users who are viewing this thread

Back
Top Bottom