Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring a Name for Access Report Output (2003)

Status
Not open for further replies.

bman6481

Technical User
May 17, 2010
8
US
Alright, I need a little help for some fellow tech heads. I am not real strong in VBA, but I have seen the code that allows a RPT output in access to have the current date and time.

I need something similar to that, but instead of a date field, I want to utilize a field on the form used to gernerate the report.

I have an input form that allows data entry for customers with thier IDs and POs. I want the report to call for the two fields.

EX. "Customer ID"-"PO Number".snp

Is this even possible, or do I need to think of something else?
 
The name is called Order Input, and the control names are called Customer_ID and PO_Number.

I actually want these to be used in naming the OUTPUT report. Each time the report is generated, I want the the Customer_ID and the PO_Number to comprise the name of the output file.

So when I run the report, the output file name will be as follows:

Customer_ID-PO_Number.snp
02413525-05172010AAC.snp

Hope that helps

 
Assuming you have a button on the Order Input form to output the snp file. Your code might look like:
Code:
Private Sub cmdOutputReport_Click()
On Error GoTo Err_cmdOutputReport_Click
    Dim stDocName As String
    Dim strTitle as String
    stDocName = "rptYourReportName"
    strTitle = Me.Customer_ID & "-" & Me.PO_Number 
    DoCmd.OutputTo acReport, stDocName, acFormatSNP, "C:\temp\Access\" & strTitle & ".snp", True
    
Exit_cmdOutputReport_Click:
    Exit Sub

Err_cmdOutputReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdOutputReport_Click
    
End Sub

[/code]

Duane
Hook'D on Access
MS Access MVP
 
Awesome... I have the code, and I will post how it works.

You ROCK...
 
Duane,

I am getting a compile error now...

COMPILE ERROR:
Method or data member not found
 
I'm having trouble seeing which line in your code is causing the error. Please understand that we can't see anything in your mdb. We don't know control or report names, data types, or anything else unless you tell us.

Can you provide your code and tell us which line is causing the issue?

Duane
Hook'D on Access
MS Access MVP
 
Unfortunately the database contains some private data... I can clear that out if that will help.

The control names have been corrected.. as the name previously provided were for a different DB I had open at the time... my apologies.

The form name is FRM_Rebuttal Entry and the unique field that I want to use as the output name is the field called DCI#. So the email output or save file would look like

DCI#.snp

rivate Sub Command139_Click()
On Error GoTo Err_Command139_Click

Dim stDocName As String
Dim strTitle As String
stDocName = "RPT_DCI Print Update"
strTitle = Me.DCI#
DoCmd.OutputTo acReport, stDocName, acFormatSNP, "C:\temp\Access\" & strTitle & ".snp", True

Exit_Command139_Click:
Exit Sub

Err_Command139_Click:
MsgBox Err.Description
Resume Exit_Command139_Click

End Sub
 
The Compile error is in the me.DCI# line according to VBA
 
Try Me.DCI_.Value rather than me.DCI# - it's a naming problem.

(I am assuming that DCI# is the name of your text box.)

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
That worked perfectly... It was a naming problem.

Thanks again guys.
 
If I wanted to email the same file...

I know I would change to the DoCmd.SendObject... but where would I put the strTitle part


Private Sub Command139_Click()
On Error GoTo Err_Command139_Click

Dim stDocName As String
Dim strTitle As String
stDocName = "RPT_DCI Print Update"
strTitle = Me.DCI_
DoCmd.OutputTo acReport, stDocName, acFormatSNP, "C:\temp\Access\" & strTitle & ".snp", True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top