custom report name?

G

Guest

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
 
D

Duane Hookom

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
 
G

Guest

Thanks for the tip,

But would it be possible to pull the information from a field on the
report for the reort name?

BRook

Duane Hookom said:
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
--

Brook said:
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
 
D

Duane Hookom

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
--

Brook said:
Thanks for the tip,

But would it be possible to pull the information from a field on the
report for the reort name?

BRook

Duane Hookom said:
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
--

Brook said:
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
 
G

Guest

Thank you...

Can you provide an example code... and where I would place the code?

Brook

Duane Hookom said:
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
--

Brook said:
Thanks for the tip,

But would it be possible to pull the information from a field on the
report for the reort name?

BRook

Duane Hookom said:
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
--

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
 
D

Duane Hookom

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
--

Brook said:
Thank you...

Can you provide an example code... and where I would place the code?

Brook

Duane Hookom said:
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
--

Brook said:
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
--

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
 
G

Guest

Thank you Duane,

I am going to give that a shot....

Thanks for your help and patience!

Brook

Duane Hookom said:
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
--

Brook said:
Thank you...

Can you provide an example code... and where I would place the code?

Brook

Duane Hookom said:
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
--

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
 
G

Guest

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








Duane Hookom said:
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
--

Brook said:
Thank you...

Can you provide an example code... and where I would place the code?

Brook

Duane Hookom said:
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
--

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
 
G

Guest

one more question for when we get the errors figured out..

Can I have the export default to a specific location?

I.E. C:\Orders\Custom\ [rptname]

Thanks,

Brook

Duane Hookom said:
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
--

Brook said:
Thank you...

Can you provide an example code... and where I would place the code?

Brook

Duane Hookom said:
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
--

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
 
D

Duane Hookom

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


Brook said:
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








Duane Hookom said:
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
--

Brook said:
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
--

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
 
D

Duane Hookom

strOutputName = "C:\Orders\..." & DLookup() & "..."

--
Duane Hookom
MS Access MVP


Brook said:
one more question for when we get the errors figured out..

Can I have the export default to a specific location?

I.E. C:\Orders\Custom\ [rptname]

Thanks,

Brook

Duane Hookom said:
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
--

Brook said:
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
--

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
 
G

Guest

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
Duane Hookom said:
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


Brook said:
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








Duane Hookom said:
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
--

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
 
D

Duane Hookom

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


Brook said:
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
Duane Hookom said:
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


Brook said:
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
--

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
 
G

Guest

The code that is mentioned below is the code on my command button on my form
to pull the data for the specific record.

The code that I was working with you on, I had on my report close feature of
my actual report, so that when I close the report after any and all changes
to the order have been made, that is when I could save the report.

Should I just combine the output to code to the command button on my form?

Brook

Duane Hookom said:
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


Brook said:
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
Duane Hookom said:
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
--

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
 
G

Guest

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

Duane Hookom said:
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


Brook said:
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
Duane Hookom said:
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
--

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
 
D

Duane Hookom

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


Brook said:
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

Duane Hookom said:
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


Brook said:
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
--

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
 
G

Guest

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

Duane Hookom said:
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


Brook said:
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

Duane Hookom said:
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
--

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
 
D

Duane Hookom

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
--

Brook said:
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

Duane Hookom said:
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


Brook said:
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
--

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
 
G

Guest

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
--

Brook said:
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

Duane Hookom said:
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
--

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
 
D

Duane Hookom

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
--

Brook said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top