|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Hi. I have a module that should loop through a table of reports, prints each report, and close each report. I know the code below works if I were to replace the code, '" & rs!ReportName & "' with the actual report name. The problem is that, as I have the code written, the line DoCmd.OpenReport '" & rs!ReportName & "', acViewNormal is commented out after the first ' and the line DoCmd.Close acReport, '" & rs!ReportName & "', acSaveYes is red, so there's something wrong there too. Any thoughts on how to rearrange this code? THANKS!
Set rs = DB.OpenRecordset("SELECT * FROM [Report]") If Not rs.EOF Then Do While Not rs.EOF DoCmd.OpenReport '" & rs!ReportName & "', acViewNormal DoCmd.Close acReport, '" & rs!ReportName & "', acSaveYes rs.MoveNext Loop End If
|
|
DoCmd.OpenReport "[" & rs!ReportName & "]", acViewNormal DoCmd.Close acReport, "[" & rs!ReportName & "]", acSaveYes
and if the report name doesn't have spaces in it, all you need is
DoCmd.OpenReport rs!ReportName, acViewNormal DoCmd.Close acReport, rs!ReportName, acSaveYes
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
"Mike C" <MikeC[ at ]discussions.microsoft.com> wrote in message news:8CF082FE-B495-48FE-9BBF-64B6904E3503[ at ]microsoft.com...
[Quoted Text] > Hi. I have a module that should loop through a table of reports, prints
each > report, and close each report. I know the code below works if I were to > replace the code, '" & rs!ReportName & "' with the actual report name. The > problem is that, as I have the code written, the line DoCmd.OpenReport '" & > rs!ReportName & "', acViewNormal is commented out after the first ' and the > line DoCmd.Close acReport, '" & rs!ReportName & "', acSaveYes is red, so > there's something wrong there too. Any thoughts on how to rearrange this > code? THANKS! > > Set rs = DB.OpenRecordset("SELECT * FROM [Report]") > If Not rs.EOF Then > Do While Not rs.EOF > DoCmd.OpenReport '" & rs!ReportName & "', acViewNormal > DoCmd.Close acReport, '" & rs!ReportName & "', > acSaveYes > rs.MoveNext > Loop > End If
|
|
The syntax would be something like the following.
Set rs = DB.OpenRecordset("SELECT * FROM [Report]")
If Not rs.EOF Then Do While Not rs.EOF DoCmd.OpenReport rs!ReportName, acViewNormal DoCmd.Close acReport, rs!ReportName 'No need to save you aren't changing the report structure rs.MoveNext Loop End If
"Mike C" <MikeC[ at ]discussions.microsoft.com> wrote in message news:8CF082FE-B495-48FE-9BBF-64B6904E3503[ at ]microsoft.com...
[Quoted Text] > Hi. I have a module that should loop through a table of reports, prints > each > report, and close each report. I know the code below works if I were to > replace the code, '" & rs!ReportName & "' with the actual report name. The > problem is that, as I have the code written, the line DoCmd.OpenReport '" > & > rs!ReportName & "', acViewNormal is commented out after the first ' and > the > line DoCmd.Close acReport, '" & rs!ReportName & "', acSaveYes is red, so > there's something wrong there too. Any thoughts on how to rearrange this > code? THANKS! > > Set rs = DB.OpenRecordset("SELECT * FROM [Report]") > If Not rs.EOF Then > Do While Not rs.EOF > DoCmd.OpenReport '" & rs!ReportName & "', > acViewNormal > DoCmd.Close acReport, '" & rs!ReportName & "', > acSaveYes > rs.MoveNext > Loop > End If
|
|
|