John Bartow
john at winhaven.net
Wed Sep 30 15:36:20 CDT 2009
This doesn't work: Public Sub PrintAllReports() 'Loops through AddressData table and prints all customer reports Dim db As Database Dim rs1 As Recordset Dim rs2 As Recordset Dim lngTrayNum As Long Dim lngAcctNum As Long Set db = CurrentDb lngTrayNum = 1 lngAcctNum = 0 Set rs1 = db.OpenRecordset("SELECT * FROM AddressData ORDER BY TrayNumber") Do While Not rs1.EOF lngTrayNum = rs1!TrayNumber.Value Set rs2 = db.OpenRecordset("SELECT * FROM AddressData ORDER BY SortPosition WHERE TrayNumber = " & lngTrayNum) Do While Not rs2.EOF lngAcctNum = rs2!Cust.Value 'DoCmd.OpenReport "rpt1", acViewNormal, , "Cust = " & lngAcctNum 'DoCmd.OpenReport "rpt2", acViewNormal, , "Cust = " & lngAcctNum DoCmd.OpenReport "rpt3", acViewNormal, , "Cust = " & lngAcctNum rs2.MoveNext Loop rs2.Close rs1.MoveNext Loop rs1.Close How do I filter an SQL based recordset? John B.