Consulting

Results 1 to 3 of 3

Thread: delay between codes

  1. #1

    delay between codes

    I have a small macros that have a couple subs that run together. Here is a sample

    Sub daily()
    Application.Run "Sales.xls!SalesQuery" -
    'Query the sales data based on the criteria entered

    Application.Run "Sales.xls!AddToRecord"

    End sub

    The problem when run the second macros (Application.Run "Sales.xls!AddToRecord") will execute before the SalesQuery is complete.

    I used the Application.Wait Now() + TimeValue("00:05:00") between the two codes and it does not work.

    Is there a way to make the query is done before execute the next code?

    Any help ideas would be greatly appreciated

    Thanks

  2. #2
    This is the error

    This action will cancel a pending Refresh Data command. Continue?

  3. #3
    Found the answer after a few hour searching all I need to do was to add .BackgroundQuery = False in part of the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •