I've built a Macro that runs 7 queries. The macro works exactly like I want, but because they are update and append queries Access prompts the user to approve of the updates and appendages. I would like to use VBA to turn off the warning messages so that the macro runs from beginning to end without interruption.
I converted the macro to VBA and the code is pretty straightforward. There are 7 DoCmd.OpenQuery commands followed by a "macro name" Exit: and "macro name" Err:. I added this code before the first DoCmd.OpenQuery line
DoCmd.SetWarnings False
Application.DisplayAlerts=False
Then at the end of the code
DoCmd.SetWarnings True
Application.DisplayAlerts=True
This doesn't turn of the messages though when I try it. Any idea what VBA code I can use to turn off all the update, and append query warnings?
edit: My VBA is
Option Compare Database
Function Spec_Maker()
On Error GoTo Spec_Maker_Err
DoCmd.SetWarnings False
Application.DisplayAlerts=False
DoCmd.OpenQuery "Query1", acViewNormal, acEdit
DoCmd.OpenQuery "Query2", acViewNormal, acEdit
DoCmd.OpenQuery "Query3", acViewNormal, acEdit
DoCmd.OpenQuery "Query4", acViewNormal, acEdit
DoCmd.OpenQuery "Query5", acViewNormal, acEdit
DoCmd.OpenQuery "Query6", acViewNormal, acEdit
DoCmd.OpenQuery "Query7", acViewNormal, acEdit
DoCmd.SetWarnings True
Application.DisplayAlerts=True
Spec_Maker_Exit:
Exit Function
spec_Maker_Err:
MsgBox Error$
Resume Spec_Maker_Exit
End Function
Application.DisplayAlerts
property; that's an Excel thing. If you're actually asking about Excel VBA code which interacts with an Access database, please clarify that point. Thanks. – HansUpOption Explicit
to the Declarations section of your Access code module. Then run Debug->Compile from the VB Editor's main menu. Fix anything the compiler complains about. – HansUp