I've done a search for this in the forum but can't find the exact answer. All I want the piece of code to do is to tell me if the query returned records. I've included my code below. At the moment it runs fine if there are records to return however it produces the following error if there are no records: Too few parameters. Expected 1. Can anyone provide a solution?
Private Sub SourceList_DblClick(Cancel As Integer)
On Error GoTo dclickErr
Dim DB As Database
Dim RS As Recordset
Dim ls_SQL As String
Dim sSelected As String
Set DB = CurrentDb
sSelected = "src_Notes_" & SourceList.ItemData(SourceList.ItemsSelected(0))
ls_SQL = "SELECT * FROM " & "[" & sSelected & "]"
Set RS = DB.OpenRecordset(ls_SQL)
If RS.RecordCount > 0 Then
MsgBox "records"
Else
MsgBox "no records"
End If
Set RS = Nothing
Set DB = Nothing
Me.RecordSource = sSelected
Exit Sub
dclickErr:
MsgBox Err.Description, vbExclamation
Err.Clear
End Sub
Private Sub SourceList_DblClick(Cancel As Integer)
On Error GoTo dclickErr
Dim DB As Database
Dim RS As Recordset
Dim ls_SQL As String
Dim sSelected As String
Set DB = CurrentDb
sSelected = "src_Notes_" & SourceList.ItemData(SourceList.ItemsSelected(0))
ls_SQL = "SELECT * FROM " & "[" & sSelected & "]"
Set RS = DB.OpenRecordset(ls_SQL)
If RS.RecordCount > 0 Then
MsgBox "records"
Else
MsgBox "no records"
End If
Set RS = Nothing
Set DB = Nothing
Me.RecordSource = sSelected
Exit Sub
dclickErr:
MsgBox Err.Description, vbExclamation
Err.Clear
End Sub