Print a reports using a combo box choice on a form (1 Viewer)

access2010

Registered User.
Local time
Today, 05:50
Joined
Dec 26, 2009
Messages
1,021
We would like to choose a report from the form in our Access 2003 database
The chosen report, which is in column 2 would have its name shown in the combo box
The print button would be clicked and the report would be previewed prior to printing or canceled.
Your assistance will be appreciated.

Thank you,
Nicole
 

Attachments

  • Print_Report_Choices_From_Forn=22.mdb
    292 KB · Views: 188

bob fitz

AWF VIP
Local time
Today, 13:50
Joined
May 23, 2011
Messages
4,719
Perhaps like attached
 

Attachments

  • Print_Report_Choices_From Bob01.mdb
    424 KB · Views: 211

JMZ

New member
Local time
Today, 07:50
Joined
Nov 20, 2020
Messages
12
Try this...
Code:
 DoCmd.OpenReport "ReportName", acViewPreview
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:50
Joined
Feb 19, 2002
Messages
43,233
I don't know what Bob did (although I'm sure it is correct). I don't ever examine "try this" solutions.

The code would be:
DoCmd.OpenReport Me.cboReport.Column(1), acViewPreview

That assumes that the first column of the RowSource is the user friendly name of the report and the second, hidden column is the name of the report object which should be more like rptAnnualRecap. Object names should never include special characters or embedded spaces. This method allows you to make a table with two columns;
UserFriendlyName (ex. Annual Recap)
ObjectName (ex. rptAnnualRecap)

The .column property of the combo is a zero-based array. We reference the first column (or the bound column) by just using Me.ControlName, but the bound column (assuming it is the first column) could also be reverenced as Me.ControlName.Column(0) or even Me.ControlName.Value. I know, way TMI:)
 

onur_can

Active member
Local time
Today, 05:50
Joined
Oct 4, 2015
Messages
180
I also agree with Pat Hartman. I never like to try this solution suggestions. You must give precise instructions. The solution to this problem looks like this.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:50
Joined
Feb 19, 2002
Messages
43,233
Hi Bob,
I don't look at them because I have no idea what might have been changed so it requires examining too many things. Just saying "try this" also makes it harder for the OP to understand the solution and either implement it in his real database or use it in a different context some time in the future. When i actually modify a database for someone, I give them a summary of what I changed to solve the problem. Such as - your column was defined as an integer and so that is why it wasn't showing any fractional amounts. You were referencing the items in the option group but you need to reference the option group control to get the value. I changed the import to link instead so you don't bloat the database by constantly adding/deleting rows, etc.

Also, if I can explain in a sentence or two and give sample code where needed, I don't make the change myself. If is a better learning experience for the OP to try to implement the instructions. The method is more likely to be remembered.
 

bob fitz

AWF VIP
Local time
Today, 13:50
Joined
May 23, 2011
Messages
4,719
Hi Bob,
I don't look at them because I have no idea what might have been changed so it requires examining too many things. Just saying "try this" also makes it harder for the OP to understand the solution and either implement it in his real database or use it in a different context some time in the future. When i actually modify a database for someone, I give them a summary of what I changed to solve the problem. Such as - your column was defined as an integer and so that is why it wasn't showing any fractional amounts. You were referencing the items in the option group but you need to reference the option group control to get the value. I changed the import to link instead so you don't bloat the database by constantly adding/deleting rows, etc.

Also, if I can explain in a sentence or two and give sample code where needed, I don't make the change myself. If is a better learning experience for the OP to try to implement the instructions. The method is more likely to be remembered.
Thank you Pat. I think you make some good points. I shall try to keep them in mind for the future.
 

Users who are viewing this thread

Top Bottom