I have a database, Form, and Report all named Intake3. I was successful in printing my report but Access prints all the records. I went to another Access site and found the following instructions that I attempted to modify to fit my database and command button:
The following procedure prints only the record that you select from the Customers form in the sample database Northwind.mdb.
1. Create a report based on the Customers table, and then name it rptPrintRecord.
2. Open the Customers form in Design view. Add a command button to the form, and then set the following command button properties:
3. Name: cmdPrintRecord4. Caption: Print Record5. OnClick: [Event Procedure] 6. Set the OnClick property to the following event procedure:
7. 8. Private Sub cmdPrintRecord_Click()9. 10. Dim strReportName As String11. Dim strCriteria As String12. 13. strReportName = "rptPrintRecord"14. strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"15. DoCmd.OpenReport strReportName, acViewPreview, , strCriteria16. 17. End Sub 18. Open the form in Form view, and then Print Record. Note that the report preview is limited to the current record from the Customer form.
Please excuse my ignorance with both Access and VB but I had a couple of questions concerning these steps:
1. I don't know exactly how to enter steps 3,4,and 5 in the properties of the command button.
2. On step 13, I changed strReportName from "rptPrintRecord" to Mine "Intake3".
3. On step 14, I changed strCriteria from "CustomerID" to mine "ClientID"
4. In addition I can't figure out how to change the name of the button to "Print " . It currently says "Command53"
Here is what my code is right now under on click:
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "intake3"
strCriteria = "[ClientID]='" & Me![ClientID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub
Private Sub Command53_Click()
End Sub
Where am I Going wrong?
The following procedure prints only the record that you select from the Customers form in the sample database Northwind.mdb.
1. Create a report based on the Customers table, and then name it rptPrintRecord.
2. Open the Customers form in Design view. Add a command button to the form, and then set the following command button properties:
3. Name: cmdPrintRecord4. Caption: Print Record5. OnClick: [Event Procedure] 6. Set the OnClick property to the following event procedure:
7. 8. Private Sub cmdPrintRecord_Click()9. 10. Dim strReportName As String11. Dim strCriteria As String12. 13. strReportName = "rptPrintRecord"14. strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"15. DoCmd.OpenReport strReportName, acViewPreview, , strCriteria16. 17. End Sub 18. Open the form in Form view, and then Print Record. Note that the report preview is limited to the current record from the Customer form.
Please excuse my ignorance with both Access and VB but I had a couple of questions concerning these steps:
1. I don't know exactly how to enter steps 3,4,and 5 in the properties of the command button.
2. On step 13, I changed strReportName from "rptPrintRecord" to Mine "Intake3".
3. On step 14, I changed strCriteria from "CustomerID" to mine "ClientID"
4. In addition I can't figure out how to change the name of the button to "Print " . It currently says "Command53"
Here is what my code is right now under on click:
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "intake3"
strCriteria = "[ClientID]='" & Me![ClientID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub
Private Sub Command53_Click()
End Sub
Where am I Going wrong?