Record Count Condition Not working

khwaja

Registered User.
Local time
Today, 22:48
Joined
Jun 13, 2003
Messages
254
I am trying to run following code before issuing an email. So if there are records in the query, I should be able to fire off an email.

If RecordCount = 0 Then
MsgBox "There are no DVs to be procesed. Please try later."
Cancel = True

Exit Sub

else ....

But this does not seem to be working as I keep getting the message even though theere are record in the query. I wonder what do I need to do to fix this.
 
Where does the value for RecordCount come from?
 
Sorry for the lack of completeness. The preceding code is as under:

Sub EmailPM() ' Being used to issue a periodic email to PMs

Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String

Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryDVFollowup", dbOpenSnapshot)
 
You need to refer to the recordset
rs.Email.RecordCount

Before that you need to move to the last record so that Access is forced to load them for the count.

rsEmail.MoveLast
 

Users who are viewing this thread

Back
Top Bottom