HowardHelp
New member
- Local time
- Today, 17:42
- Joined
- Feb 1, 2021
- Messages
- 26
My database is based and dissected from the old Northwind database which works well enough for me BUT the database does not support searching for inverted commas e.g. its is fine but search it’s and it produces a pop up error message as follows
Run-time error ‘3075’
Syntax error (missing operation) in query expression ‘[Title] like ‘it’s*”.
If I click on debug it highlights this code
Me![Find Sub form].Form.RecordSource = MyRecordSource
The full code below with the highlighted code in it.
Private Sub Show_Tracks_Button_Click()
' Create a WHERE clause using search criteria entered by user and
' set RecordSource property of Find Sounds Subform.
Dim MySQL As String, Mycriteria As String, MyRecordSource As String
Dim ArgCount As Integer
Dim Tmp As Variant
' Initialize argument count.
ArgCount = 0
' Initialize SELECT statement.
MySQL = "SELECT * FROM Title WHERE "
Mycriteria = ""
' Use values entered in text boxes in form header to create criteria for WHERE clause.
AddToWhere [Look For Title], "[Title]", Mycriteria, ArgCount
AddToWhere [Look For Album], "[Album]", Mycriteria, ArgCount
AddToWhere [Look For Artist], "[Artist]", Mycriteria, ArgCount
AddToWhere [Look For Year], "[Year]", Mycriteria, ArgCount
AddToWhere [Look For Category], "[Category]", Mycriteria, ArgCount
AddToWhere [Look For Notes], "[Notes]", Mycriteria, ArgCount
AddToWhere [Look For Copy 1], "[Copy 1]", Mycriteria, ArgCount
AddToWhere [Look For Copy 2], "[Copy 2]", Mycriteria, ArgCount
AddToWhere [Look For Rating], "[Rating]", Mycriteria, ArgCount
' If no criterion specifed, return all records.
If Mycriteria = "" Then
Mycriteria = "True"
End If
' Create SELECT statement.
MyRecordSource = MySQL & Mycriteria
' Set RecordSource property of Find Sub form.
Me![Find Sub form].Form.RecordSource = MyRecordSource (highlighted code when error occurs)
' If no records match criteria, display message.
' Move focus to Clear button.
If Me![Find Sub form].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "No records match the criteria you entered.", 48, "No Records Found"
Me![Clear Button].SetFocus
Else
' Enable control in detail section.
Tmp = EnableControls("Detail", True)
' Move insertion point to Find Sounds Subform.
Me![Find Sub form].SetFocus
End If
End Sub
The question can this be fixed, search inverted comers in the database TABLE direct are fine, any help will be much appreciated.
Run-time error ‘3075’
Syntax error (missing operation) in query expression ‘[Title] like ‘it’s*”.
If I click on debug it highlights this code
Me![Find Sub form].Form.RecordSource = MyRecordSource
The full code below with the highlighted code in it.
Private Sub Show_Tracks_Button_Click()
' Create a WHERE clause using search criteria entered by user and
' set RecordSource property of Find Sounds Subform.
Dim MySQL As String, Mycriteria As String, MyRecordSource As String
Dim ArgCount As Integer
Dim Tmp As Variant
' Initialize argument count.
ArgCount = 0
' Initialize SELECT statement.
MySQL = "SELECT * FROM Title WHERE "
Mycriteria = ""
' Use values entered in text boxes in form header to create criteria for WHERE clause.
AddToWhere [Look For Title], "[Title]", Mycriteria, ArgCount
AddToWhere [Look For Album], "[Album]", Mycriteria, ArgCount
AddToWhere [Look For Artist], "[Artist]", Mycriteria, ArgCount
AddToWhere [Look For Year], "[Year]", Mycriteria, ArgCount
AddToWhere [Look For Category], "[Category]", Mycriteria, ArgCount
AddToWhere [Look For Notes], "[Notes]", Mycriteria, ArgCount
AddToWhere [Look For Copy 1], "[Copy 1]", Mycriteria, ArgCount
AddToWhere [Look For Copy 2], "[Copy 2]", Mycriteria, ArgCount
AddToWhere [Look For Rating], "[Rating]", Mycriteria, ArgCount
' If no criterion specifed, return all records.
If Mycriteria = "" Then
Mycriteria = "True"
End If
' Create SELECT statement.
MyRecordSource = MySQL & Mycriteria
' Set RecordSource property of Find Sub form.
Me![Find Sub form].Form.RecordSource = MyRecordSource (highlighted code when error occurs)
' If no records match criteria, display message.
' Move focus to Clear button.
If Me![Find Sub form].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "No records match the criteria you entered.", 48, "No Records Found"
Me![Clear Button].SetFocus
Else
' Enable control in detail section.
Tmp = EnableControls("Detail", True)
' Move insertion point to Find Sounds Subform.
Me![Find Sub form].SetFocus
End If
End Sub
The question can this be fixed, search inverted comers in the database TABLE direct are fine, any help will be much appreciated.