Message box not working all of the time

SteveL13
SteveL13 used Ask the Experts™
on
I have a strange thing happening with a message box.  Here is the code of an onclick event of a command button:

    DoCmd.SetWarnings False

    DoCmd.RunSavedImportExport "ImportEstimateWon"
    DoCmd.RunSavedImportExport "EstimateWonOutbuys"

    DoCmd.SetWarnings True

    MsgBox "Estimate imported.  Proceed to job schedule.  Be sure to check for outside purchase information."

The problem is this... if there is no "EstimateWonOutbuys" import the message box does not appear.  If both imports take place then the message box does appear.  I need it to appear in either case.  There are cases where there is no import to be done for "EstimateWonOutbuys".

--Steve


 
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
do you have error handling codes that goes with the codes above?

or, is there an
       on error resume next        line
Top Expert 2016

Commented:
comment this two lines, then test your codes again

' DoCmd.SetWarnings False


'  DoCmd.SetWarnings True

Author

Commented:
I commented those two lines out and the message box did not popup when only the first import existed.
Top Expert 2016

Commented:
what about the first question?
Database Architect / Application Developer
Top Expert 2007
Commented:
Just say NO to DoCmd.Setwarnings - very dangerous and it masks errors you want to know about.

Try this:
 
    With CurrentDb
          .Execute  "ImportEstimateWon" , dbFailOnError
          .Execute  "EstimateWonOutbuys" , dbFailOnError
    End With

    MsgBox "Estimate imported.  Proceed to job schedule.  Be sure to check for outside purchase information."

mx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial