W
Wylie C
I have a SQL statement that is supposed to take the selection of a listbox
(lstTitle) and display all the records in tblSongs that match the criteria.
In the following code, I get a message that it cannot execute the strSQL
statement. I also tried the docmd.opentable "tblSongs" before trying to
execute the SQL statement.
I also tried every combination of single and double quotes around the
strTitle part of the SQL statement and connot get it to work. Can someone
point out what it wrong with the code? Thank you.
Private Sub cmdFindAlbum_Click()
Dim strSQL As String
Dim strTitle As String
strTitle = Me.lstTitle
strSQL = "Select * FROM tblSongs WHERE tblSongs.[Album] = " & Chr(34) &
strTitle & Chr(34) & Chr(59) & ""
Debug.Print strSQL
CurrentDb.Execute strSQL 'I get the error message here.
End Sub
(lstTitle) and display all the records in tblSongs that match the criteria.
In the following code, I get a message that it cannot execute the strSQL
statement. I also tried the docmd.opentable "tblSongs" before trying to
execute the SQL statement.
I also tried every combination of single and double quotes around the
strTitle part of the SQL statement and connot get it to work. Can someone
point out what it wrong with the code? Thank you.
Private Sub cmdFindAlbum_Click()
Dim strSQL As String
Dim strTitle As String
strTitle = Me.lstTitle
strSQL = "Select * FROM tblSongs WHERE tblSongs.[Album] = " & Chr(34) &
strTitle & Chr(34) & Chr(59) & ""
Debug.Print strSQL
CurrentDb.Execute strSQL 'I get the error message here.
End Sub