We help IT Professionals succeed at work.
Get Started

Insert Msg box in MS Access VBA Code

route217
route217 asked
on
495 Views
Last Modified: 2012-07-24
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

Open in new window

Comment
Watch Question
President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE