Need a button to view a specific report so I can print it.

Marq

Well-known Member
Joined
Dec 13, 2004
Messages
914
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Access 2007

I want to create a button to view a specific report. The report, of course, is the information from one record in a table. The button I have created opens up the report but it shows every record..for example I have 22 records thus far, so when I click on my "view Report" button I get 22 pages to view. I just want one, specific, report to show up.

Which brings me to my second issue..I want to have a button that when clicked a window pops up asking what report I want to view, I type in the report number, then I can click print to print that specific report.

Would I have make a query with a "Like" command in order to do any of the above?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If your report is created from a query, then what you do is go into the query and from the field you want to set as the record, go into the criteria and place in something like this:

[Enter the record number to print]

This will then display a parameter box and you would type in the number of the record

If you want the option to show all then thats when you would use the like

like[Enter the record number to print]&"*"

Then save and close the query then test your button
 
Upvote 0
On occaison I have a user that wants to print in a report what is in a particular record that is displayed in a form on the screen. I use a command button and assign the following code to that button. It is important to note that you must have a unique identifer for the record.

Code:
Private Sub RecordReport_Click()
On Error GoTo RecordReport_Click_Err
    Dim stDocName As String
    stDocName = "ReportName"
   DoCmd.OpenReport stDocName, acViewReport, , "[ID] = Forms![FormName]!ID"
RecordReport_Click_Exit:
    Exit Sub
RecordReport_Click_Err:
    MsgBox Error$
    Resume RecordReport_Click_Exit
End Sub

Make sure you use your own form names and field name. Additionally, my report is generated from a query using the fields from the table bound to the form.

HTH
Alan
 
Upvote 0
If your report is created from a query, then what you do is go into the query and from the field you want to set as the record, go into the criteria and place in something like this:

[Enter the record number to print]

This will then display a parameter box and you would type in the number of the record

If you want the option to show all then thats when you would use the like

like[Enter the record number to print]&"*"

Then save and close the query then test your button


works!..thanks
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top