Hi,
In a standard module (by opposition to a class module), add the line
Option Explicit
(or check the "Require Variable Declaration" option under Tools | Options,
Editor Tab) among the first lines, then, type:
Public Sub MySub( )
The editor should respond by adding a
End Sub
You will type your VBA code between these lines. MySub can be changed to
any name you like.
To run a select query, a line of code can be:
DoCmd.RunSQL "QueryNameHere"
So, you can use a test condition, like:
---------------------------
Public Sub MySub()
On Error Resume Next ' if there is an error, continue
If 0 <> DCount

"*", "SavedQuery1") Then
DoCmd.RunSQL "SavedQuery1"
Else
MsgBox "No data from SavedQuery1", vbInformation + vbOKOnly
End If
If 0 <> DCount

"*", "SavedQuery2") Then
DoCmd.RunSQL "SavedQuery2"
Else
MagBox "No data from SavedQuery2", vbInformation + vbOKOnly
End If
Debug.Assert 0=Err.number ' we assumed there was no error
' so, assert it
End Sub
------------------------
Note that we added some very basic error handling: if an error occurs, the
end-user is probably clueless about how to solve it, so we decided to
continue, but, while we will test-debug our application, if an error occur,
we should be able to examine the Err.Number and Err.Description, and,
eventually, rerun the code, step by step, in debug mode (which is then much
easier than with macros). Furthermore, since we modified nothing, we don't
have to undo (rollback) any changes, if an error occur. That basic error
handling sounds quite appropriate, for a first draft.
Hoping it may help,
Vanderghast, Access MVP