Automating running of queries, based on results

  • Thread starter Thread starter H J
  • Start date Start date
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.
 
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
 
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>
 
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
 
Back
Top