Hi all you helpful folks,
Can anybody tell my why the code below does not work?
When I click the cmd button, the only msgBox that shows is the one that starts Didn't work. I want to be able to show the MsgBox stating there are no records. Help??????
Private Sub Command30_Click()
Dim db As Database
Dim rs As Recordset
Dim n As Integer
Dim strSQL As String
Set db = CurrentDb
strSQL = "Select * from [No records Query]"
Set rs = db.OpenRecordset(strSQL)
n = rs.RecordCount
If n < 0 Then
MsgBox "Your query has no records"
Else
MsgBox "Didn't work - Else fired this"
End If
rs.Close
db.Close
Set db = Nothing
End Sub
Can anybody tell my why the code below does not work?
When I click the cmd button, the only msgBox that shows is the one that starts Didn't work. I want to be able to show the MsgBox stating there are no records. Help??????
Private Sub Command30_Click()
Dim db As Database
Dim rs As Recordset
Dim n As Integer
Dim strSQL As String
Set db = CurrentDb
strSQL = "Select * from [No records Query]"
Set rs = db.OpenRecordset(strSQL)
n = rs.RecordCount
If n < 0 Then
MsgBox "Your query has no records"
Else
MsgBox "Didn't work - Else fired this"
End If
rs.Close
db.Close
Set db = Nothing
End Sub