Export to Specific Folder Based on Report Field?

B

Brook

Good Day,

I have an orders form that I use for two types of orders: Custom &
Program, after an order is input, I click a button that prints my order form
& saves it to a specified folder. However at this point all my order forms go
to one folder. I would like to have it set up so that if it is custom order
it is saved to C:\Custom Orders and if it is a Program Order it is saved to
folder C:\Program Orders.

Also, I would like to have the code set up so that if the the file name
already exist, it won't overright the file, but add a new file with an added
extension of some sort? I.E. if the file is CustomOrder_08 and I tried to
export the same order form again it would add an extension like
CustomOrder_08_1 and so on... Any ideas? suggestions?

IF anyone has any ideas on how to incorporate the ability to save as a PDF
please let me know... I have Adobe Acrobat Professional.

Thanks,

Brook

Below is my current code:

Start Code:

Private Sub cmdPrintPreview_Click()

Dim strReportName As String
Dim strCriteria As String
Dim strOutputName As String

Me.Dirty = False

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"
strCriteria = "[orderid]= " & Me![orderid]

DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

If MsgBox("Do you want to save the report to disk?", vbYesNo +
vbQuestion, "Save Report") = vbYes Then

strOutputName = "D:\Karma Imports\Program & Custom Orders\Custom
Orders\" & (Me!ordnum) & " - " & Format(Date, "mm_dd_yyyy") & ".snp"

If Me.PrintOrder = False Then
Me.PrintOrder = True
Me.SystemPrintDate = Date
End If


DoCmd.OutputTo acOutputReport, strReportName, acFormatSNP,
strOutputName, True
End If

End If
End Sub


End Code
 
S

SA

Brook:

If you take a look at our PDF and Mail Library it can help you automate this
process, you'll find it on our web site in the developer tools area. To
determine if a file already exists, before you output it, you can use the
DIR vba command, then change the target output file name.

Hope that helps
 
B

Brook

Thanks Steve,

I will take a look at your website. How do I use the DIR VBA command?
Also, how do I send to a specific folder?

Thanks,

brook

SA said:
Brook:

If you take a look at our PDF and Mail Library it can help you automate this
process, you'll find it on our web site in the developer tools area. To
determine if a file already exists, before you output it, you can use the
DIR vba command, then change the target output file name.

Hope that helps
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

Brook said:
Good Day,

I have an orders form that I use for two types of orders: Custom &
Program, after an order is input, I click a button that prints my order
form
& saves it to a specified folder. However at this point all my order forms
go
to one folder. I would like to have it set up so that if it is custom
order
it is saved to C:\Custom Orders and if it is a Program Order it is saved
to
folder C:\Program Orders.

Also, I would like to have the code set up so that if the the file name
already exist, it won't overright the file, but add a new file with an
added
extension of some sort? I.E. if the file is CustomOrder_08 and I tried to
export the same order form again it would add an extension like
CustomOrder_08_1 and so on... Any ideas? suggestions?

IF anyone has any ideas on how to incorporate the ability to save as a
PDF
please let me know... I have Adobe Acrobat Professional.

Thanks,

Brook

Below is my current code:

Start Code:

Private Sub cmdPrintPreview_Click()

Dim strReportName As String
Dim strCriteria As String
Dim strOutputName As String

Me.Dirty = False

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"
strCriteria = "[orderid]= " & Me![orderid]

DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

If MsgBox("Do you want to save the report to disk?", vbYesNo +
vbQuestion, "Save Report") = vbYes Then

strOutputName = "D:\Karma Imports\Program & Custom Orders\Custom
Orders\" & (Me!ordnum) & " - " & Format(Date, "mm_dd_yyyy") & ".snp"

If Me.PrintOrder = False Then
Me.PrintOrder = True
Me.SystemPrintDate = Date
End If


DoCmd.OutputTo acOutputReport, strReportName, acFormatSNP,
strOutputName, True
End If

End If
End Sub


End Code
 

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