Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing of queries and Macros

Status
Not open for further replies.

Costefran

Technical User
Jan 2, 2008
197
GB
Can anyone help

I am running a query and macro in code but seem to have a timing issue

The macro is intended to run after the query as the actions of the macro are based on query results

Although I have placed the RunMacro after the OpenQuery method in code I think I am running the macro before the results of the query are complete and shown as values on the form

Is there any way in code to only allow the macro to run once the query has finished?

Thanks
 
Here it is

DoCmd.SetWarnings (False)
stDocName = "Capital Budgets Table Update Decription Usage to1"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings (True)

stDocName = "Cash Flow Approval Form After Description of Work Update"
DoCmd.RunMacro stDocName
Me.Dirty = False
 
Try:

DoCmd.OpenQuery stDocName

And if that doesn't work, try:

Code:
'SQL string - you can probably cut and paste from
'the query
strSQL="Update [Capital Budgets] Set [Decription Usage] =1"
'Watch out - you will not get a warning
CurrentDB.Execute strSQL, dbFailOnError
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top