Run query after another closes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I programatically run a query after another closes.

Basically I want to run a series of queries. But I don"t want them all to
run at the same time. I want one to run and after the user closes it the
next runs and so on.

TIA
 
I don't get the idea behind this. You want to run a set of queries but you
don't want them to run all at once. What if a user doesn't close the query
for a very long time or closes it improperly. Are you referring to regular
select queries? Seems to me like you have to use some sort of counter which
will tell which query has been opened and closed. Based on the counter you
can open the next query. Or somelting like that I assume.
 
Assumes qryOne and qryTwo actually return records (SELECT, UNION, Crosstab,
etc.)
************
Sub MySub

DoCmd.OpenQuery "qryOne", acViewNormal, acReadOnly
Do While IsLoaded("qryOne", acQuery)
Do Events
Loop

DoCmd.OpenQuery "qryTwo", acViewNormal, acReadOnly
Do While IsLoaded("qryTwo", acQuery)
Do Events
Loop
' etc...
End Sub

Public Function IsLoaded(strObjName As String, Optional lngObjType As
acObjecttype = acForm) As Boolean
' Returns True (non-zero) if strObjName is Open, False(0) if not Open or
doesn't exist.
' (subform status can't be tested this way)
'
' The 12 legal acObjectTypes include: acForm (default), acTable,
acQuery, acReport (see ObjectBrowser for complete list)

On Error Resume Next
IsLoaded = (SysCmd(acSysCmdGetObjectState, lngObjType, strObjName) <> 0)
End Function
*******************************************************

HTH,
 
Back
Top