Discussion Locked
0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am creating an Access 2000 form which has a control button on it that when clicked will print a report containing the data from the form. The report is based on a querry. When the querry runs it asks the user to input a specific record # so that it can select only that record and print it in the report. I would like to add some VB code to automate the print button on my form so that when it is clicked it will be able to select the current record # from the form, pass that to the querry, and then print the report using that informaiton and without asking the user which record # to print. Any ideas. Thanks in advance.
3 replies
by chris.lewis
How about something like this:
Private Sub pbPrint_Click()
On Error GoTo Err_pbPrint_Click
DoCmd.OpenReport "rptReport", acViewPreview, , "[idTableID]=" & Me.txtIDOfTable.Value
Exit_pbPrint_Click:
Exit Sub
Err_pbPrint_Click:
MsgBox Err.Description
Resume Exit_pbPrint_Click
End Sub
Where txtIDOfTable is the field holding your record number on the form, and [idTableID] is the table id in the query (Same fields, just diff names here for clarity)
by pc_tek
Thank you. This was what I was looking for.
by pc_tek
This question was closed by the author
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
Discussion Locked
What Makes a Business Website Effective in 2026
2 helpful
10 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
1 helpful
3 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies
Discussion Locked
Best Ways to Improve Website Visibility
0 helpful
5 replies