Limiting Report to Current Record

E

Ernie

I have a form based on a query for viewing customer
records (selected from a 3rd party database). The query
can return from 1 to 1000 records depending on the
criteria that you enter. This query works fine, the
desired records match all of the criteria entered. This
form works fine, it lists only those records returned by
the query and its subforms likewise lists only the
contacts directly related to each record in this query.

I included a command button on the main form which will
allow you to print from one to six reports based the
records returned in this query. This also works fine, if
the query returns 4 records then the print button prints
each record as appropriate (i.e. if I choose to print all
six reports for these 4 customers then I get 24 reports as
expected).

Now my form displays one record at a time, but when I hit
the print button, I print all of the records from the
query. What I want to do is print just the current record
from my screen. EX: if my query returns 500 records and I
am viewing record # 463, then I want to print record 463,
not all 500 of them.

I've done a bit of searching here and on other access
sites and haven't been able to find anything helpful.

The On Click event for my print button looks like this:

Private Sub CmdCustomPrint_Click()

Dim ArrReports(5, 1) As String
Dim i As Integer
'put the actual report and checkbox names next
ArrReports(0, 0) = "rptCustomData"
ArrReports(1, 0) = "rptCustomDataAfterHoursContacts"
ArrReports(2, 0) = "rptCustomDataComments"
ArrReports(3, 0) = "rptCustomDataNotes"
ArrReports(4, 0) = "rptCustomDataSchedules"
ArrReports(5, 0) = "rptCustomDataZoneListings"
ArrReports(0, 1) = "chkSiteInformation"
ArrReports(1, 1) = "chkAfterHoursContacts"
ArrReports(2, 1) = "chkComments"
ArrReports(3, 1) = "chkNotes"
ArrReports(4, 1) = "chkSchedules"
ArrReports(5, 1) = "chkZoneListings"

For i = 0 To 5
If Me.Controls(ArrReports(i, 1)) = True Then
DoCmd.OpenReport ArrReports(i, 0), acViewNormal
End If
Next i

End Sub

Where the 'ArrReports(i, 1)' is a checkbox for whether you
want to print that report or not. Clicking all reports in
a large selection can add up to a lot of paper.

What do I need to add to this to get just the current
record?
 
R

Roger Carlson

On my website (see sig below) is a small sample database called
"PrintOneLabel.mdb" which illustrated 3 different ways to do this. Don't be
put off by the "label" business though. A label report works just like any
other report, it just has colums. The same methods will work for regular
reports.
 
E

Ernie

Thanks, I'll check into that.

By the way, your download, option "A third way to do it"
prints '#error' three times instead of a label.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top