Run one query, then another, then another...

this thread is getting lengthly mr. access. need some assistance? :D
 
this thread is getting lengthly mr. access. need some assistance? :D
We're having a bit of a banter here Adam, so you're more than welcome to rejoin in the discussions and make some interesting contributions :D
 
We're having a bit of a banter here Adam, so you're more than welcome to rejoin in the discussions and make some interesting contributions :D

i am a boring guy and I offer nothing interesting. so go ahead and fight to the death on it....good luck!
 
i'm sure most would disagree. the OP would be would delighted to hear more ideas.
 
Just out of curiousity and for the benefit of readers that may stumble upon this thread, what approach did you eventually take?
 
I went with this solution, as it shows an hour glass and also provides a description of what is happening....

Private Sub RunAllQueries___Click()

DoCmd.Hourglass True

Dim myQueries() As String, i As Integer, myDb As Database
Set myDb = CurrentDb
ReDim myQueries(3)
myQueries(0) = "0 - Clear Out yealry accamend - required tbl"
myQueries(1) = "0 - Clear Out yearly acc amend tbl"
myQueries(2) = "0 Clear out ALL DATA table"
myQueries(3) = "0 Clear out Merged_Stock Table"

For i = 0 To UBound(myQueries)
DoCmd.Echo True, "Running query " & i + 1 & " of 4 please wait...."
myDb.Execute myQueries(i)
Next

DoCmd.Hourglass False
End Sub
 
Looks good :) One thing though, remember your error handling code.

Thanks for posting back with your success.
 
Very bad....but I never have put in error handling, but just read up on it and it make sense to have!! However, after thinking it would be easy to add this fails "Label not defined" and highlights the second line.....any ideas?

Private Sub RunAllQueries___Click()
On Error GoTo Err_RunAllQueries
DoCmd.Hourglass True

Dim myQueries() As String, i As Integer, myDb As Database
Set myDb = CurrentDb
ReDim myQueries(3)
myQueries(0) = "0 - Clear Out yealry accamend - required tbl"
myQueries(1) = "0 - Clear Out yearly acc amend tbl"
myQueries(2) = "0 Clear out ALL DATA table"
myQueries(3) = "0 Clear out Merged_Stock Table"

For i = 0 To UBound(myQueries)
DoCmd.Echo True, "Running query " & i + 1 & " of 4 please wait...."
myDb.Execute myQueries(i)
Next

DoCmd.Hourglass False
Exit_RunAllQueries:
End Sub
Err_RunAllQueries:
MsgBox Err.Description
Resume Exit_RunAllQueries
End Sub
 
DoCmd.Hourglass False
Exit_RunAllQueries:
End Sub

Change that to Exit Sub. You end a routine/function, but exit if you want to "break" out of it.
 
Code:
Err_RunAllQueries:
    MsgBox Err.Description
[COLOR=Blue]DoCmd.Hourglass False[/COLOR]
    Resume Exit_RunAllQueries
End Sub

The blue was the main reason I reminded you of error handling. include that too.
 
No worries. Actually put that before the message box.

Have fun with the rest of your db.:)
 

Users who are viewing this thread

Back
Top Bottom