Sunday, 15 February 2015

excel vba - VBA/Access: Removing warning prompts -


I have created a macro that runs 7 questions. The macro works just as I want, but because they update and add queries, Access encourages the user to update and approve the app. I would like to use VBA to stop the warning message so that the macro ends up to the end of the blockage.

I changed the macro to VBA and the code is very simple. There are 7 DoCmd.OpenQuery followed by a "macro name" exit: and "macro name" error: I have already added this code to the DoCmd.OpenQuery line

DoCmd.SetWarnings False

Application.DisplayAlerts = False

Then Code end

DoCmd.SetWarnings True

Application.DisplayAlerts = True

This message does not turn on, however when I Any attempt to try this I can use the VBA code to close all updates and add query warnings? In

Edit: My VBA

  substitute database function Spec_Maker (comparison) 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: use the function to begin spec_Maker_Err: MsgBox error $ then Spec_Maker_Exit End function  

set warning Should generally be avoided, since this warning gives off globally, and you will very carefully UL to turn them on again, even in case of errors .

A great way to get rid of warnings is to use the query to not data changes. Instead, copy the INSERT or UPDATE statement SQL VBA and execute it with:

  CurrentDb.Execute "INSERT IN ...", dbFailOnError  

Also see:


No comments:

Post a Comment