yes
Main Topics
Browse All TopicsIn my procedure, I loop through credit memo records. The number of credit memos will vary per execution. Per credit memo record, I want to open the credit memo report. However, I find that once the report is opened, even though the code continues to execute, no more reports will open. I am opening the reports with a simple Do command. Any assistance will be greatly appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
'Update RMA Header Table
Set rsRmaCount = db.OpenRecordset("Select Distinct RMAID from LocalCreditMemos where selected = true")
rsRmaCount.MoveFirst
Do Until rsRmaCount.EOF
Set rsRma = CurrentDb.OpenRecordset("S
rsRma.MoveFirst
If rsRma.Fields(0) <> "Completed" And rsRma.Fields(0) <> "Closed" Then
MsgBox "RMA " & rsRmaCount.Fields(0) & " cannot be closed becuase RMA Status is not Completed."
Else
If CloseRMA(rsRmaCount.Fields
CurrentDb.Execute ("Update RMA set RMA.RMAStatus = 'Closed', RMA.Comments = RMA.Comments + ' This RMA was Closed by " & gstrUser & " on " & Date & ".' " _
& " Where rmaid = " & rsRmaCount.Fields(0) & "")
MsgBox "RMA Successfully closed"
End If
End If
rsRma.Close
Set rsRma = Nothing
'Open Credit Memo Request Report
DoCmd.OpenReport "CreditMemoRequestMulti", acViewPreview
rsRmaCount.MoveNext
Loop
In A2003 and I presume A2007, you cannot have more than a single instance of a report open at any time. A way around it might be to 'copy' the report to CreditMemoRequestMulti1, and CreditMemoRequestMulti2, and CreditMemoRequestMulti3 and then deleteCreditMemoRequestMul
DoCmd.OpenReport "CreditMemoRequestMulti" & i, acViewPreview
Why do you have to loop through records in code instead of using an SQL query to select the records on which you wish to report? If you could accomplish teh selection of records in an SQL query you could then use it as the recordsource for a standard Access report showing all the items you wish to report upon in the same (single) report instance.
If you really must use a loop-based approach, then why not use the loop not to run N reports but to populate a temporary table with the keys of the records you are selecting? You could then use an SQL query joined to the temp table keys as the source for your report...
It's a much simpler approach than trying to instantiate multiple instances of the same report object - which as far as I know is not possible to do in Access.
-Stewart
From the code you have supplied in your second post you must be manually outputting your reports from the preview window as they are opened, then closing the report manually as well.
An alternative approach is to use DoCmd.OpenReport to send the report direct to the printer (not the print previewwindow. Although I don't have A2007, I guess the PDF add-in should function as any other does - as an alternative printer driver which will allow you to print to PDF directly. That way you would not require multiple instances of the report object at all. Unfortunately, OpenReport does not give you a means of specifying the filename for the PDF file.
Alternatively, if other formats would do (e.g. Excel or Text or RTF) you could use the DoCmd.OuputTo method to output (export) the report to another format. You would be able to specify the filename for each pass if you went this route.
-S
While I agree, it would be much more normal to simply send the report to the print queue for each iteration - you can have more than a single instance of a report open at any time.
However you then lack the ability to filter in the WhereCondition (or OpenArgs) methods.
Though it seems you're filtering by other means, adapting data in each iteration, so you could be OK - though the process in general seems problematic, for example you're, somewhat unnecessarily, both opening a recordset in your loop on the table RMA and then issueing a separate update statement upon it.
Business Accounts
Answer for Membership
by: GRayLPosted on 2009-06-05 at 11:11:40ID: 24558899
You mean:
DoCmd.OpenReport ??