M
Mona-ABE
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()
Dim acApp
Dim strReportName
Dim strReportPath
Dim PrintPONum
'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 =
"\\m1srv04\contractmanagement$\Contract_Management.mdb"
'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
'Security Warning
'Opening \\m1srv04\contractmanagement$\Contract_Management.mdb
'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
SELECT SNAPSHOT
'FROM A LIST OF OTHER OPTIONS LIKE RTF, DAP, XLS 97-2003, TXT, XLS 5-7,
HTML, XML.
'MY USERS WON'T KNOW WHAT TO PICK! I NEED IT TO AUTOMATICALLY GO TO A
SNAPSHOT!
acApp.DoCmd.OutputTo 3, strReportName, acFormatSNP, strReportPath &
"PrintPO.snp", True
' Close Access
acApp.Quit
'Clear object variable
Set acApp = Nothing
End Sub
If there's a better way to handle this, please advise!
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()
Dim acApp
Dim strReportName
Dim strReportPath
Dim PrintPONum
'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 =
"\\m1srv04\contractmanagement$\Contract_Management.mdb"
'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
'Security Warning
'Opening \\m1srv04\contractmanagement$\Contract_Management.mdb
'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
SELECT SNAPSHOT
'FROM A LIST OF OTHER OPTIONS LIKE RTF, DAP, XLS 97-2003, TXT, XLS 5-7,
HTML, XML.
'MY USERS WON'T KNOW WHAT TO PICK! I NEED IT TO AUTOMATICALLY GO TO A
SNAPSHOT!
acApp.DoCmd.OutputTo 3, strReportName, acFormatSNP, strReportPath &
"PrintPO.snp", True
' Close Access
acApp.Quit
'Clear object variable
Set acApp = Nothing
End Sub
If there's a better way to handle this, please advise!