troubleshooting Question

Insert Msg box in MS Access VBA Code

Avatar of route217
route217Flag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft Access
6 Comments2 Solutions496 ViewsLast Modified:
Hi Experts

I need a message box to appear when the following vba code is run to say the following and close down once the macro is complete

"This May Take Several minutes to run...........Please Wait!!!"

Private Sub Export_Quarterly_Reports_Click()

DoCmd.Echo False, "Exporting, Please Wait.........."

Dim RootMIdir As String
Dim FilePath As String
Dim xlPath As String
Dim rs As DAO.Recordset, sql As String
Dim xlobj As Object, wb As Object, ws As Object


xlPath = "\Report Templates\"
RootMIdir = "\Output Files"

Set xlobj = CreateObject("excel.application")
     Set wb = xlobj.Workbooks.Open(xlPath & "BB_Template.xls")
     Set ws = wb.Worksheets("AA_DATA")
     
          sql = "SELECT *"
          sql = sql & " FROM _DATA"
           
          Set rs = CurrentDb.OpenRecordset(sql)
          ws.Range("a2").CopyFromRecordset rs
                  
         wb.SaveAs Filename:=RootMIdir & "\REPORT" & Format(Now(), " dd-mmm-yy") & ".xls"
         
     wb.Close
     xlobj.Quit

Set ws = Nothing
Set wb = Nothing

Set xlobj = Nothing
Set rs = Nothing
         
DoCmd.Echo True
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros