I am trying to open a recordset from a query and count the number of records in it. Very simple task you might think. However every which way people tell me to do it dosnt work. The code so far is as follows:
'Note EmailCount is the Query Name
Dim DB As Database
Dim RS As Recordset
Dim MyRecordCount As Integer
Set DB = CurrentDb
Set RS = DB.OpenRecordset(EmailCount)
With RS
.MoveFirst
.MoveLast
MyRecordCount = .Recordcount
MsgBox "there are " & MyRecordCount
End With
With this code i get a Type mismatch on the line ....
Set RS = DB.OpenRecordset(EmailCount)
Can anyone help?
'Note EmailCount is the Query Name
Dim DB As Database
Dim RS As Recordset
Dim MyRecordCount As Integer
Set DB = CurrentDb
Set RS = DB.OpenRecordset(EmailCount)
With RS
.MoveFirst
.MoveLast
MyRecordCount = .Recordcount
MsgBox "there are " & MyRecordCount
End With
With this code i get a Type mismatch on the line ....
Set RS = DB.OpenRecordset(EmailCount)
Can anyone help?