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.
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.