I have the following code which I am trying to determine if any records are returned given the criteria in the SQL statement. When I step through the code and it attempts to set rs with the results, I can see in the debug window that the SQL statement that is built is being repeated three times!? There will be two records that meet the condition and I'm not sure if that is related to why my SQL statement is being repeated...
Here is the code:
Option Compare Database
Option Explicit
Public db As Database
Public rs As Recordset
Public SQL As String
Public Sub Renew_Credentials()
Set db = CurrentDb
SQL = SQL & "SELECT Count(*) FROM Physician_Insurance WHERE (((Physician_Insurance.Renew_Credential_Date1)<=Date()+60) AND ((Physician_Insurance.Noted)=No))"
Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
If (rs.RecordCount >= 1) Then
MsgBox "Records"
Else
MsgBox "No Records"
End If
End Sub
Am I making this too difficult? All I want to do is see if the query returns any records. Any suggestions are appreciated.
Here is the code:
Option Compare Database
Option Explicit
Public db As Database
Public rs As Recordset
Public SQL As String
Public Sub Renew_Credentials()
Set db = CurrentDb
SQL = SQL & "SELECT Count(*) FROM Physician_Insurance WHERE (((Physician_Insurance.Renew_Credential_Date1)<=Date()+60) AND ((Physician_Insurance.Noted)=No))"
Set rs = db.OpenRecordset(SQL, dbOpenDynaset)
If (rs.RecordCount >= 1) Then
MsgBox "Records"
Else
MsgBox "No Records"
End If
End Sub
Am I making this too difficult? All I want to do is see if the query returns any records. Any suggestions are appreciated.