Exporting Reports Selected by a tick box

Number11

Member
Local time
Today, 13:20
Joined
Jan 29, 2020
Messages
635
Hi, is it possible to have say a form with 10 separate options to run different reports if they tick the box its included in the batch run if not ticketed then its excluded ?
 
Of course, there's even several ways you can try. For example, instead of checkboxes, you could use a multi select listbox.
 
the list or report to print that exists in tReports would have a Ticked box (yes/no)
then when the user clicks submit, code would cycle thru the list ,printing those ticked.

Code:
sub btnPrintRpts_click()

vDir = "c:\temp\"

set rst = currentdb.openrecordset("select * from tReport where [tick]=true})
with rst
while not .eof

     vRpt = .fields("RptName").value & ""
      vFile = vDir &  vRpt & ".pdf"
          'to file
      docmd.OutputTo acOutputReport ,vRpt ,acFormatPDF, vFile 
          'to printer
      docmd.OpenReport vRpt

      .movenext
  wend
end with
end sub
 
the list or report to print that exists in tReports would have a Ticked box (yes/no)
then when the user clicks submit, code would cycle thru the list ,printing those ticked.

Code:
sub btnPrintRpts_click()

vDir = "c:\temp\"

set rst = currentdb.openrecordset("select * from tReport where [tick]=true})
with rst
while not .eof

     vRpt = .fields("RptName").value & ""
      vFile = vDir &  vRpt & ".pdf"
          'to file
      docmd.OutputTo acOutputReport ,vRpt ,acFormatPDF, vFile
          'to printer
      docmd.OpenReport vRpt

      .movenext
  wend
end with
end sub

Thanks sounds a good idea, so the reports i wish to run are exporting query to excel and i am using this method.......

Code Tags Added by UG
Please use Code Tags when posting VBA Code

Please read this for further information:-
Please feel free to Remove this Comment

Code:
Dim rst
Dim XL As Excel.Application
Set XL = CreateObject("excel.application")
Dim vFile

vFile = "Template LOCATION"
Set rst = CurrentDb.OpenRecordset("QUERYNAME")
If rst.RecordCount = 0 Then
    Dialog.Box "No RECORDS FOUND!", vbInformation, "NOTICE"
  
    Else
  
   rst.MoveLast
   Dialog.Box "A Total Of: " & rst.RecordCount & " RECORDS WILL BE EXPORTED!", vbInformation, "NOTICE"

   rst.MoveFirst

With XL
   .Visible = False
   .Workbooks.Open vFile
   .Sheets("NEW").Select
   .Range("A4").Select
   .ActiveCell.CopyFromRecordset rst
   .ActiveWorkbook.SaveAs ("LOCATION HERE")
   .ActiveWorkbook.close
   .Application.Quit
 
Last edited by a moderator:

Users who are viewing this thread

Back
Top Bottom