Abandoning ship if no records in recordset

Sally

Registered User.
Local time
Today, 00:15
Joined
Feb 6, 2002
Messages
12
I'd be grateful if someone would look at the following for me. I have a database converted from 97 to 2000. I want to check for the presence of records in a table produced by a make table query and if it is empty, abandon ship. This is what I have:

'Check to see if any students in report
Dim rstStudents As Dao.Recordset
Dim dbs As Database
Set dbs = CurrentDb
Set rstStudents = dbs.OpenRecordset("Group for reports")
If rstStudents.RecordCount = 0 Then
MsgBox "No students are in the database for this group", vbOKOnly, "Error"
Else
'Go ahead and merge

Shell "C:\Program Files\Microsoft Office\Office\Winword.exe /mMergeReports", _ vbNormalFocus
End if

Many thanks
Sally



[This message has been edited by Sally (edited 06-07-2002).]
 
Dim rstStudents As Dao.Recordset
Dim dbs As Database
Set dbs = CurrentDb
Set rstStudents = dbs.OpenRecordset("Group for reports")
If rstStudents.RecordCount = 0 Then
MsgBox "No students are in the database for this group", vbOKOnly, "Error"
Exit Sub
Else
'Go ahead and merge
 
If DCount("*","Groups for reports")<= 0 Then
MsgBox "No students..."
Exit Sub
Else
Do whatever
End if

[This message has been edited by Jack Cowley (edited 06-07-2002).]
 
Thanks very much - that was a great help. As a matter of interest, why does the "If" expression still execute the Shell call even when the recordcount is zero?

Sally
 

Users who are viewing this thread

Back
Top Bottom