Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.
Code is as follows: Dim RSLocation As Recordset Dim location As String Dim sqlstring As String Dim RSReports As ADODB.Recordset Dim query As String Dim file As String DoCmd.Hourglass True DoCmd.SetWarnings False Set RSLocation = CurrentDb.OpenRecordset("ReportLocation") If RSLocation.RecordCount = 0 Then MsgBox ("No location is present in the Report Location table") Exit Function End If RSLocation.MoveFirst location = RSLocation.Fields(1).Value RSLocation.Close Set RSLocation = Nothing If Right(location, 1) <> "\" Then location = location + "\" End If '2 Move through the OutputReport table and select records with print flag set sqlstring = "select QueryName, ReportName from OutputReport where Print= -1" Set RSReports = New ADODB.Recordset RSReports.CursorLocation = adUseClient RSReports.Open sqlstring, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly If Not (RSReports.EOF) And Not (RSReports.BOF) Then RSReports.MoveFirst While RSReports.EOF = False And RSReports.BOF = False query = RSReports.Fields(0).Value file = location + RSReports.Fields(1).Value On Error GoTo PrintError '3 Check to see if the file exists - if so remove (kill it) If Dir(file) <> "" Then Kill file End If '4 Run the Report DoCmd.OutputTo acOutputQuery, query, acFormatXLS, file, False RSReports.MoveNext Wend '5 Tidy up RSReports.Close Set RSReports = Nothing DoCmd.Hourglass False DoCmd.SetWarnings True MsgBox "Report out Completed", vbInformation Exit Function PrintError: If Err.Number = 53 Then Resume Next Else: MsgBox (Err.Description) End If DoCmd.Hourglass False DoCmd.SetWarnings True End Function
|ust html in ms/access WebBrowswer||11||45|
|Replace special characters in Access VBA||8||33|
|Ms Access How Can I Display Values in a Query Differently Then They Appear? N = New or U = Used||10||19|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
11 Experts available now in Live!