
Originally Posted by
akel210
pkstormy, I used DAO version provided by ssanfu and in his verision doesn't have the "Docmd.SetWarnings False" line.
And I tired deleting this line from DAO code
MsgBox "About to execute query name: " & rs!Name '(for testing. Comment out when live)
But this doesn't show the prompt box for the update queries. by deleting this line i just don't see the message "About to execute query name...."
any other idea or I am doing it wrong?
thanks,
If you want to see the name of the query that is executing, below is a modification that uses the Status Bar to display the query name and doesn't require a response (like the message box) to continue to the next query.
Code:
Sub runQueries()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim bStatusBar As Variant
Set db = CurrentDb
strSQL = "SELECT Name FROM MSysObjects WHERE Name Like '0010 01*'"
'(note: if the above syntax doesn't work, you can also create a query using the above, save it as qryMyQueriesToRun, and then...
' strSQL = "Select * from qryMyQueriesToRun"
'save current status bar state
bStatusBar = Application.GetOption("Show Status Bar")
' show status bar
Application.SetOption "Show Status Bar", True
Set rs = db.OpenRecordset(strSQL)
If rs.BOF And rs.EOF Then
rs.Close
Set rs = Nothing
MsgBox "No queries to run."
Else
rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF
' show which query is executing - see status bar
Application.SysCmd acSysCmdSetStatus, "Executing query: " & rs!Name
CurrentDb.Execute rs!Name, dbFailOnError
rs.MoveNext
Loop
End If
' clear status bar message
Application.SysCmd acSysCmdClearStatus
' set status bar visible state to original state
If Not bStatusBar Then
Application.SetOption "Show Status Bar", False
End If
'clean up and exit
rs.Close
Set rs = Nothing
Set db = Nothing
MsgBox "Done"
End Sub
(the added lines are in blue)