Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-24-2013, 11:53 PM   #1
tgonzalez
Newly Registered User
 
Join Date: Sep 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tgonzalez is on a distinguished road
Opening a Report based on combobox selection

Hey everyone,

I am trying to run a report based on a combobox selection. I have three different reports, each for the three different items in the combo box. I just don't know how to code it so when I run the report, it picks up the name in the combo box and opens the correct report. This is what my code looks like for the button that will run the report:

Private Sub Command7_Click()
DoCmd.OpenReport ("Signers Authorized for Check Writing"), acViewPreview, , WhereCondition = [BTrans] = "Check Writing"
DoCmd.OpenReport ("Signers Authorized for Stop Payment"), acViewPreview, , WhereCondition = [BTrans] = "Stop Payments"
DoCmd.OpenReport ("Signers Authorized for Wires"), acViewPreview, , WhereCondition = [BTrans] = "Wires"
End Sub

The problem is, that as soon as I hit the Run Report button, all three reports open up, so it is not reading what is in the combo box. The quotes, "Check Writing" , "Stop Payments" and "Wires" are the actual selections in the combobox and [BTrans] is the name of the combobox.

Any help would be awesome!!!!


tgonzalez is offline   Reply With Quote
Old 09-25-2013, 12:01 AM   #2
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,658
Thanks: 99
Thanked 1,500 Times in 1,415 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: Opening a Report based on combobox selection

Assuming the BoundColumn of the combo holds the name of the reports.
Code:
DoCmd.OpenReport Forms!formname.comboname, acViewPreview, , "[BTrans]='Check Writing'"
Note the syntax of the Where argument, particularly the single quotes.
Galaxiom is offline   Reply With Quote
Old 09-25-2013, 12:08 AM   #3
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,658
Thanks: 99
Thanked 1,500 Times in 1,415 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: Opening a Report based on combobox selection

BTW Assuming "Check Writing" is one of a number of fixed possible values it is a better practice to store this information as numeric values in the table.

A lookup table is used to store the text represented by the numbers just once. It is considerably more efficient to store and search the number rather than the text.

Galaxiom is offline   Reply With Quote
Old 09-25-2013, 03:21 PM   #4
tgonzalez
Newly Registered User
 
Join Date: Sep 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tgonzalez is on a distinguished road
Re: Opening a Report based on combobox selection

Thank you for answer. I still don't see how that will open up a specific report. There are three reports. One for each of the selections on the combo box. I think that code is to open a report based on a form??
tgonzalez is offline   Reply With Quote
Old 09-25-2013, 03:28 PM   #5
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,658
Thanks: 99
Thanked 1,500 Times in 1,415 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: Opening a Report based on combobox selection

The first argument of the OpenReport Method is a string that defines the name of the report to be opened. If the combo has the name of the report then that is what will be opened.

Galaxiom is offline   Reply With Quote
Reply

Tags
button , code , combobox , reports , wherecondition

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Button to filter report based off combobox selection Neobeowulf Reports 26 07-14-2016 08:59 AM
based on combobox one selection , combobox two must display those values compu General 1 07-29-2012 11:02 PM
Opening Report based on ListBox selection stanbridge Forms 3 08-08-2011 08:54 PM
Filter Subform ComboBox based on Master Form ComboBox selection azammalick Forms 1 12-16-2009 12:27 PM
Print report based on ComboBox selection TunaonToast Reports 4 12-14-2009 06:04 AM




All times are GMT -8. The time now is 09:24 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World