1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Private Sub Commande4_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Dim strSQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT DISTINCT [Dealer/Distributor Number] FROM Query_Active_Dealer_List_Update")
Set qdf = dbs.QueryDefs("Query_Active_Dealer_List_Update")
BaseSQL = qdf.SQL
With rst
Do Until .EOF
strSQL = Left(BaseSQL, Len(BaseSQL) - 3) & " WHERE [Dealer/Distributor Number] = '" & ![Dealer/Distributor Number] & "';"
qdf.SQL = strSQL
DoCmd.OutputTo acOutputReport, "Main_Report", "RichTextFormat", "C:\Documents and Settings\larocma\Dealer_Scorecards\" & ![Dealer/Distributor Number] & ".doc"
.MoveNext
Loop
.Close
End With
qdf.SQL = BaseSQL
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub |
Partager