G
Guest
So your saying to have one command button for the user to preview the report,
then they would close the report.
Then then they would choose another button to save the report?
Well, if that is what it comes down to... I will do that..
Thanks for all your help and patience..
BRook
then they would close the report.
Then then they would choose another button to save the report?
Well, if that is what it comes down to... I will do that..
Thanks for all your help and patience..
BRook
Duane Hookom said:If you want it reviewed first, add a command button to save the report.
--
Duane Hookom
MS Access MVP
--
Brook said:Yes I have tried other options like saving the report on load of the
report,
but I still come back to the issue that I would like the report saved
after
it has been reveiwed and all errors fixed.
Brook
Duane Hookom said:I don't chain events like that. It's an "old guy" kinda thing.
I think that is where your error was coming from. If you removed the code
and placed in the code following the code that opens the report it might
not
error. Did you try some alternatives? Did it fix your problem?
--
Duane Hookom
MS Access MVP
--
Thanks Duane,
Just out of curiousity, why is it not a good idea to put the code in a
report event?
What would you recommend in order for me to accomplish the report
saved
after on the report closing/exit?
Brook
:
I think you 2585 error is due to the fact that you are running the
code
in
the on close of the report. I wouldn't place code in a report that
outputs
the report.
--
Duane Hookom
MS Access MVP
Duane,
thanks for all your help... I won't burden you with more questions
about
my
new errors regarding the error 2585.
I have found some information and belive what I need to do is
temporarily
close my form, then reopen it after the file save.
Thanks again for you help!
Brook
:
What happened to all the outputto code?
I'm not sure what your code is doing that generates the error.
Learn
how
to
comment out lines and/or set break points to see what is causing
your
issue.
--
Duane Hookom
MS Access MVP
Duane,
Thanks for the updated code, but I am still getting a Run Time
Error,
but
now its : 2585.
This Action Cannot be carried out while processing a form or
report
event.
I am pretty sure this is refereing to the fact that this report
is
being
pulled from a form to pull the record data based on the forms
ordnum.
Here is my code for the print preview button on my form:
begin code:
Private Sub cmdPrintPreview_Click()
Dim strReportName As String
Dim strCriteria As String
If NewRecord Then
MsgBox "This record contains no data. Please select a
record
to
print or Save this record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rptcustomorders(Export)"
strCriteria = "[ordernumber]= " & Me![OrderNumber]
'strCriteria = "[lngSalespersonID]='" &
Me![lngSalespersonID]
&
"'"
DoCmd.OpenReport strReportName, acViewPreview, ,
strCriteria
End If
End Sub
End Code:
Thanks Brook
Also thanks for the tip about hte send to a specific location...
Brook
:
My bad,
Private Sub Report_Close()
Dim strReportName As String
Dim strOutputName as String
strReportName = "rptYourReportObjectName"
strOutputName = DLookup("[OrdNum]", "qryinventory") & _
" - " & Format(Date, "dd/mm/yyyy")
DoCmd.OutputTo acOutputReport, strReportName, "Rich Text
Format",
_
strOutputName, True
End Sub
--
Duane Hookom
MS Access MVP
Duane,
I set the code up, but when I run it, I am getting a run time
error
"2103"
The Report Name 'NW-0001 - 04/21/2004' you entered in either
the
property
sheet or macro is misspeclled or referes to a report that
doesn't
exist.
and when I click the debug, it goes to this line.
DoCmd.OutputTo acOutputReport, strReportName, "Rich Text
Format",
_
"Test.rtf", True
here is all the code that I have:
begin code:
Private Sub Report_Close()
Dim strReportName As String
strReportName = DLookup("[OrdNum]", "qryinventory") & _
" - " & Format(Date, "dd/mm/yyyy")
DoCmd.OutputTo acOutputReport, strReportName, "Rich Text
Format",
_
"Test.rtf", True
End Sub
end code
Thanks
Brook
:
This would be the code to run the report
Dim strReportName As String
strReportName = Dlookup("[DepartmentName]",
"qselMyReportRS") &
_
" - " & Format(Date,"mmmm")
DoCmd.OutputTo acOutputReport, strReportName, "Snapshot
Format", _
"TestReport.snp", True
strReportName = Dlookup("[DepartmentName]",
"qselMyReportRS") &
_
" - " & Format(Date,"mmmm") & " 2nd Copy"
DoCmd.OutputTo acOutputReport, strReportName, "Snapshot
Format",
_
"TestReport2.snp", True
--
Duane Hookom
MS Access MVP
--
Thank you...
Can you provide an example code... and where I would place
the
code?
Brook
:
A report is based on a recordsource/query that contains
fields.
You
can
use
code to retrieve values from the recordsource/query.
DLookup()
is
one
method
of grabbing a value from a table or query.
--
Duane Hookom
MS Access MVP
--
Thanks for the tip,
But would it be possible to pull the information from
a
field
on
the
report for the reort name?
BRook
:
You can provide a name for instance the following code
outputs
the
same
report to two different names. You could ask the user
for
a
name
prior
to
the OutputTo.
Dim strReportName As String
strReportName = "rptPrintArray"
DoCmd.OutputTo acOutputReport, strReportName,
"Snapshot
Format",
"TestReport.snp", True
DoCmd.OutputTo acOutputReport, strReportName,
"Snapshot
Format",
"TestReport2.snp", True
--
Duane Hookom
MS Access MVP
--
message
Is there a way that I can add feature so that when I
perform
my
outputto
function, there is a customized report name already
available
in
the
save
as
box?
I would like to choose something like: "invoice
number "
&
[invoicenumber]
Thanks,
Brook