Group:  Microsoft Access ยป microsoft.public.access.modulescoding
Thread: Commenting problem

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Commenting problem
Mike C 18.07.2006 15:03:02
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
Re: Commenting problem
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 18.07.2006 15:54:33
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


Re: Commenting problem
"John Spencer" <spencer[ at ]chpdm.edu> 18.07.2006 15:58:02
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


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net