I have the following code when a pdf file is generated it replaces the older file where as I want a auto serial number to be added so the older file is not replaced. How can I do that.
Private Sub Command19_Click()
On Error GoTo Err_Handler
Const ReportName = "General Sales"
Const MESSAGETEXT = "No customer selected."
Dim strCriteria As String
' build string expression to filter report
' to selected customer
strCriteria = "CoId = " & Me.cboCustomers
' make sure a customer is selected
If Not IsNull(Me.cboCustomers) Then
' open report filtered to selected customer
DoCmd.OpenReport ReportName, _
View:=acViewPreview, _
WhereCondition:=strCriteria
DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="General Sales", OutputFormat:=acFormatPDF, Outputfile:="C:\Users\Filtech\Desktop\PDF Reports\AC-Title Sales" & " " & Format(Date, "dd-mmm-yyyy") & ".PDF"
Else
MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_Here
End Sub