Print only current record

J

Jason

Using Access 2007.

Hi all,
I'm trying to figure out how to show a report only displaying the current
record. I created a db using the Issues Database as a template. It has a
form called Issue Details which has a button that prints a report of all
issues.
I created a new button and want to be able to print the same report but only
with the record that is selected on the form.
I searched the 'net and based on what I found I added this to the button's
Click event:
--------------------------------------
Private Sub Command188_Click()

On Error GoTo Err_Command188_Click

Dim MyForm As Form
Dim record_num As Long
Dim StrReportName As String


stDocName = "Issue Details"
StrReportName = "RA_BRL"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
record_num = MyForm.CurrentRecord
DoCmd.OpenReport StrReportName, acPreview, record_num, record_num


Exit_Command188_Click:
Exit Sub

Err_Command188_Click:
MsgBox Err.Description
Resume Exit_Command188_Click

End Sub
--------------------------------------

With the above code, I get an error that says that it cannot find the object
'1'. Make sure that the object exists. I'm not sure what this could be since
I haven't named anything as '1'.

Any suggestions on how I could achieve this?

Thanks.
 
G

Guest

Assuming IssueID is the numeric primary key of the table in the form and
report, try:
DoCmd.OpenReport StrReportName, acPreview, , "IssueID = " & record_num
 
J

Jason

Thanks, Duane. Works like a charm.
Duane Hookom said:
Assuming IssueID is the numeric primary key of the table in the form and
report, try:
DoCmd.OpenReport StrReportName, acPreview, , "IssueID = " & record_num
 

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