Automating running of queries, based on results

H

H J

I have a database with 6 queries, currently I have to manually run each of
these, but I want to automate them by clicking a button and letting them all
do their job.

The problem is that on one of them, I need to review the results before
proceeding with the next one. But, I only need to review the results if
there are any, if the query comes up empty, all is good and I can continue.

How can I code this so that if the query A returns no results, query B runs,
if query A has results, then those results are displayed and query B does
not run (I do not need to run query B until query A has no results).

Thanks.
 
C

Clifford Bass

Hi,

I take it that the first one is a select query and the others are
action queries. Is that accurate? If so, you could try something like this
(untested):

If DCount("*", "qryA") = 0 Then
DoCmd.OpenQuery "qryB"
DoCmd.OpenQuery "qryC"
DoCmd.OpenQuery "qryD"
DoCmd.OpenQuery "qryE"
DoCmd.OpenQuery "qryF"
Else
DoCmd.OpenQuery "qryA"
End If

Clifford Bass
 
J

John W. Vinson

Hi,

I take it that the first one is a select query and the others are
action queries. Is that accurate? If so, you could try something like this
(untested):

If DCount("*", "qryA") = 0 Then
DoCmd.OpenQuery "qryB"
DoCmd.OpenQuery "qryC"
DoCmd.OpenQuery "qryD"
DoCmd.OpenQuery "qryE"
DoCmd.OpenQuery "qryF"
Else
DoCmd.OpenQuery "qryA"
End If

Clifford Bass

If B through F are action queries you might do better to use

Dim db As DAO.Database
Set db = CurrentDb
If DCount("*", "qryA") = 0 Then
db.Execute "qryB", dbFailOnError
db.Execute "qryC", dbFailOnError
<etc>
 
D

dad

yes do their job
Clifford Bass said:
Hi,

I take it that the first one is a select query and the others are
action queries. Is that accurate? If so, you could try something like
this
(untested):

If DCount("*", "qryA") = 0 Then
DoCmd.OpenQuery "qryB"
DoCmd.OpenQuery "qryC"
DoCmd.OpenQuery "qryD"
DoCmd.OpenQuery "qryE"
DoCmd.OpenQuery "qryF"
Else
DoCmd.OpenQuery "qryA"
End If

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top