By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

Using a report multiple times

P: n/a
I have table of customer information. For each record in the
table, I'd like to output it to Snapshot passing in a report
as the type. I'd like to use the same report for every customer.
The problem I'm having in my VB code is that when I loop through
the records and output the report to Snapshot, the information
in the report remains to be the first record. When outputting
the report, it doesn't move to the next record.

I'm new to Access, and I'm not sure as to what I need
for the report to recognize the current record. I've looked in
the newsgroup, but have tried everything from refreshing
to requery, opening the report, closing it. I don't
think I know where I need to put it, or fully
understand how reports work. My VB code
does get input from user. Can any one help?

Here is a sample pseudocode:

Set db = Currendb()
Set rs = db.OpenRecordset ()

While not rs.EOF
DoCmd.Outputto acReport,reportname,acFormatSNP,dir,false
rs.Movenext

End

Thank you,
Nhien

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Nhien,
you never filter the report!!! Granted, this is probably ugly, but it
should work.

Public Sub OutputReportsToRTF()

Set rs = DBEngine(0)(0).QueryDefs("qryCustomer_A").OpenReco rdset

While Not rs.EOF
DoCmd.OpenReport "Invoice", acViewPreview, , "[CustomerID]=" &
rs.Fields("CustomerID")
DoCmd.OutputTo acReport, "Invoice", acFormatSNP, "rpt" &
rs.Fields("CustomerID") & ".snp", False
DoCmd.Close acReport, "Invoice", acSaveNo
rs.MoveNext
Wend

rs.Close
Set rs = Nothing

End Sub

Nov 13 '05 #2

P: n/a
Nhien,
you never filter the report!!! Granted, this is probably ugly, but it
should work.

Public Sub OutputReportsToRTF()
'this is my query that retrieves the CustomerID's that I want to create
invoices for...
Set rs = DBEngine(0)(0).QueryDefs("qryCustomer_A").OpenReco rdset

'passing the individual customerID's to the OpenReport command so 'I
get a single report per customer. (not one with multiple customers)
While Not rs.EOF
DoCmd.OpenReport "Invoice", acViewPreview, , "[CustomerID]=" &
rs.Fields("CustomerID")

'--output said report
DoCmd.OutputTo acReport, "Invoice", acFormatSNP, "rpt" &
rs.Fields("CustomerID") & ".snp", False
DoCmd.Close acReport, "Invoice", acSaveNo
rs.MoveNext
Wend

rs.Close
Set rs = Nothing

End Sub

Nov 13 '05 #3

P: n/a
Thank you all for your help. The suggestions
worked and I will remember to filter a
report next time.

-Nhien

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.