J
Jan :\)
Hi all
Access 2007 Pro Plus, Vista Ultimate SP2
I am preparing a small app for a friend who is handicapped, and am trying to make things as simple as possible for them to use. I am trying to limit the number of functions and clicks necessary to accomplish tasks as much as possible, and would like to try an idea.
I want to add a small button on the report form that will print the report when clicked. I have done this on display forms to print as a report, but, not on a report form. In trying to add such a button to the report form in 2007 I am not being offered the option for any functions, such as Report>Print, for the command button.
I know that I can add the Quick Print icon to the QAT in 2007, but, the QAT is not available in 2003 or prior versions, so I have to create such functions in a manner that can be used in older versions.
I am looking for a bit of code that I can put behind the button that will print the report. I have been trying to get it set up, but, so far am not winning.
Here is the code that I have tried behind the print button on the report, which I have set to display on screen only,
*******************Start Code********************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "rptMisc"
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
***************End Code********************
When I try to print I get the following error message:
"Miscosoft Office Access can't find the rptMisc you reference in Object Name argument."
I have print buttons working on the display forms ok, and if nothing else, they can print out the display form as a report. But, I would really rather that they have the report to print out.
Here is the code behind the Print button for the display forms, which are set to display on screen only. I'm not sure this is the best code set up for this either, although, it does print out as it should.
**********Start Code*************************************
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "frmMisc"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
*******************End Code**************************
Any help would be very much appreciated.
Jan
Access 2007 Pro Plus, Vista Ultimate SP2
I am preparing a small app for a friend who is handicapped, and am trying to make things as simple as possible for them to use. I am trying to limit the number of functions and clicks necessary to accomplish tasks as much as possible, and would like to try an idea.
I want to add a small button on the report form that will print the report when clicked. I have done this on display forms to print as a report, but, not on a report form. In trying to add such a button to the report form in 2007 I am not being offered the option for any functions, such as Report>Print, for the command button.
I know that I can add the Quick Print icon to the QAT in 2007, but, the QAT is not available in 2003 or prior versions, so I have to create such functions in a manner that can be used in older versions.
I am looking for a bit of code that I can put behind the button that will print the report. I have been trying to get it set up, but, so far am not winning.
Here is the code that I have tried behind the print button on the report, which I have set to display on screen only,
*******************Start Code********************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "rptMisc"
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
***************End Code********************
When I try to print I get the following error message:
"Miscosoft Office Access can't find the rptMisc you reference in Object Name argument."
I have print buttons working on the display forms ok, and if nothing else, they can print out the display form as a report. But, I would really rather that they have the report to print out.
Here is the code behind the Print button for the display forms, which are set to display on screen only. I'm not sure this is the best code set up for this either, although, it does print out as it should.
**********Start Code*************************************
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "frmMisc"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
*******************End Code**************************
Any help would be very much appreciated.
Jan