Jan 29 2021 10:19 AM
Hello,
I am converting a database from Paradox to Access. I have limited Access experience. I am trying to print a single record on a report launched from a button on the form. I duplicated some code I found on another forum changing the form name, report name and field. When I press the button the report launches but it is blank, no output. The code I used is below. UNIT is the data field for the data and each record has a unique number. UNIT is not the primary key.
Option Compare Database
Private Sub Command394_Click()
End Sub
Private Sub command399_Click()
DoCmd.OpenReport "FLEET-MACHINE DATA SHEET", acViewPreview, , _
"[UNIT]=Forms!frmFLEET_MASTER_DEVELOP"
End Sub
Private Sub Print_Machine_Detail_Click()
End Sub
Blank output below.
I tried modifying the code:
Option Compare Database
Private Sub Command394_Click()
End Sub
Private Sub command399_Click()
DoCmd.OpenReport "FLEET-MACHINE DATA SHEET", acViewPreview, , _
"[UNIT]=Forms!frmFLEET_MASTER!UNIT" '""
End Sub
Private Sub Print_Machine_Detail_Click()
End Sub
This launches a box which allows me to input the unit # and output to the report. I would like to code it so the user does not have to input any variable to run the report.
Jan 30 2021 02:49 PM
SolutionJan 30 2021 05:13 PM
Feb 02 2021 01:56 PM
Thanks for the coding, it works better but still requires the user to input the unit number. Is there a way to print the record selected on the form without user input?
I found another issue, I have a number of machines in inventory where the stock number has a dash "-" in it. this causes the button to fail.
Thanks again for the assistance, it is very helpful for a neophyte such as myself.
Jan 30 2021 02:49 PM
Solution