V
vman92
Rst.Filter = "CustomerNumber = " & CustomerID
The filter doesn't appear to be working. I get one file with all
customers.
' Usage: PrintAllCustomers("Reportnamehere")
Public Sub PrintAllCustomers(ReportName As String)
Dim ADOCon As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim Folder As String ' to hold directory information
'now lets ask directory you want to save
Folder = InputBox("Where do you want to save files?", "Destination
Folder", Application.CurrentProject.Path)
'if canceled leave the sub without processing.
If Folder = "" Then Exit Sub
Set ADOCon = Application.CurrentProject.Connection 'get current
connection
Set Rst = New ADODB.Recordset 'to query current customers
'open recordset and load all data we need into recordset
'I added "WHERE Print=True" to SQL statement which will
'only print the customers we want
Rst.Open "SELECT ReportName, CustomerNumber FROM WebInfo", ADOCon,
adOpenForwardOnly
Do While Not Rst.EOF 'start sending all reports to files
CustomerID = Rst!CustomerNumber 'set necessary global variables
before print to file
Filename = Folder & "\" & Rst!ReportName & ".SNP" 'set folder
and filename.
Rst.Filter = "CustomerNumber = " & CustomerID
'send report to file
DoCmd.OutputTo acOutputReport, ReportName, acFormatSNP,
Filename, True
Rst.MoveNext 'next customer
Loop
Rst.Close
Set Rst = Nothing
End Sub
Want to export one report for each customer in SNP format.From the following:
The filter doesn't appear to be working. I get one file with all
customers.
' Usage: PrintAllCustomers("Reportnamehere")
Public Sub PrintAllCustomers(ReportName As String)
Dim ADOCon As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim Folder As String ' to hold directory information
'now lets ask directory you want to save
Folder = InputBox("Where do you want to save files?", "Destination
Folder", Application.CurrentProject.Path)
'if canceled leave the sub without processing.
If Folder = "" Then Exit Sub
Set ADOCon = Application.CurrentProject.Connection 'get current
connection
Set Rst = New ADODB.Recordset 'to query current customers
'open recordset and load all data we need into recordset
'I added "WHERE Print=True" to SQL statement which will
'only print the customers we want
Rst.Open "SELECT ReportName, CustomerNumber FROM WebInfo", ADOCon,
adOpenForwardOnly
Do While Not Rst.EOF 'start sending all reports to files
CustomerID = Rst!CustomerNumber 'set necessary global variables
before print to file
Filename = Folder & "\" & Rst!ReportName & ".SNP" 'set folder
and filename.
Rst.Filter = "CustomerNumber = " & CustomerID
'send report to file
DoCmd.OutputTo acOutputReport, ReportName, acFormatSNP,
Filename, True
Rst.MoveNext 'next customer
Loop
Rst.Close
Set Rst = Nothing
End Sub