Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

Print Report/Label VBA Based On Control Box Value

Copper Contributor

Hey All,


I am currently running a program to print pathology labels for work based on a simple form and table that refreshes, opens form, and auto prints to the label maker based on the specifications in the report.



Private Sub BtnPrintVial_Click()
    D = Now()
    T = Now()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport "62VIAL"
End Sub



The first part of the VBA ensures that the Date and Time is refreshed to the current time, and the form is refreshed so that the report picks up the label in the query.


Rather than clicking "BtnPrintVial" 3 or 4 times if I have multiple vials of blood / samples, I am hoping to have a Number Value in a Text Box with a default value of 1 (easy) and if I need additional labels I can change the number to what I need. (e.g. 3 vials of blood, change it to 3, click the button, 3 labels will print).


I know that there is software out there to do this, but this allows full customisation to my needs, and is lower cost.


I have searched for the better part of two days for an answer, but no luck.


Any tips? Would it maybe be better building it outside of VBA?


Thanks All!

2 Replies


You can based your Report on a Query and Open the Report with "WhereCondition"