I'm using a DB in Access 2000 file format with data access pages. I have a
button on the page to produce a purchase order. Currently, the data access
page and the report run off the same query. This is the code I've used to
produce the PO, please especially make note of my comments in CAPS:
Public Sub PrintPurchaseOrder()
'Sets variable value of the purchase order number the DAP is currently on,
and that will be produced.
PrintPONum = Cstr(PONum1.value)
'Locates the Access DB
Const SAMPLE_DB_PATH =
'Report name to open and print
strReportName = "rptPurchaseOrder"
'Path to save final purchase order report
strReportPath = "\\m1srv04\contractmanagement$\"
' Start Access and open contract management database.
Set acApp = GetObject(SAMPLE_DB_PATH, "Access.Application")
'I WANT THIS TO ALL OCCUR IN THE BACKGROUND, BUT CURRENTLY IT OPENS
ACCESS VISIBLY AND
'HAS A DIALOG BOX THAT SAYS
'This file may not be safe if it contains code that was
'intended to harm your computer.
'Do you want to open this file or cancel the operation?
'Buttons are: Cancel Open More Info
acApp.Visible = False
'Opens the report in Access and filters to the DAP variable set at the
beginning of the procedure
acApp.DoCmd.OpenReport strReportName, 2,, "PONum = " & "'" & PrintPONum &
"'" & ""
'Outputs the report to a snapshot and saves it
'MY PURPOSE HERE IS TO VIEW AND PRINT THE REPORT ONLY.
'IS THERE A WAY OF DOING THIS FROM THE DAP AND WITHOUT OPENING ACCESS?
'(FOR CASES WHERE SOMEONE DOESN'T HAVE ACCESS ON THEIR MACHINE?)
'ALSO, EVEN THOUGH I TELL IT THE FORMAT TO OUTPUT TO BELOW (acFormatSNP),
'A DIALOG BOX OPENS THAT STILL ASKS ME THE OUTPUT FORMAT, AND I HAVE TO
'FROM A LIST OF OTHER OPTIONS LIKE RTF, DAP, XLS 97-2003, TXT, XLS 5-7,
'MY USERS WON'T KNOW WHAT TO PICK! I NEED IT TO AUTOMATICALLY GO TO A
acApp.DoCmd.OutputTo 3, strReportName, acFormatSNP, strReportPath &
' Close Access
'Clear object variable
Set acApp = Nothing
If there's a better way to handle this, please advise! :)