Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 19th, 2008, 11:20 AM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using a drop down list in a query

I have a database with numerous sub-units contained within an overhead unit. I need to review reports for each of the sub-units separately so I would like to create a drop-down list so a user can just highlight the sub-unit they wish to view and bring up the report. Can this be done? I can't seem to get a drop-down list to perform in a query and I need a query to run a report.....right??
Any help would be greatly appreciated.

Reply With Quote
  #2 (permalink)  
Old March 19th, 2008, 11:48 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create a combo box using the wizard, and have it take unique values from the table that has this parameter column. I'll assume the column name is SubUnit.

If your report is based on a query, then add this to the SubUnit column Criteria line in the query designer:

[Forms]![frmMySelectionForm].[cboSubUnitComboBox]

Then EVERY time you open the report, it will look for the combo box, take the selected value, and open the report with only those subunits.

If you want the report to run without criteria, then you can either create a copy of the report just for sub units and create a copy of the query just for sub units with this criteria and open that when someone wants the sub units, and open your current report when they want all the info.

Alternatively, on the button to open the report (same report as current) where the user selects criteria, then just do this:

Dim sUnit As String
Dim sLink As String
Dim sDoc As String

sDoc = "rptMyCurrentReport"

sUnit = Me.cboSubUnitComboBox

sLink = "[SubUnit] = '" & sUnit & "'"

DoCmd.Open Report sDoc, , , sLink

The sLink variable should be in the WHERE clause section of the DoCmd line. You may also want to check to validate a selection.

Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #3 (permalink)  
Old March 19th, 2008, 11:50 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I should also mention that if you use the combo box wizard to create the look up, and then use the button wizard to open the report, it will ask you if the report should use any parameter on the form, and you can select the combo box and Access will build all of this for you.

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #4 (permalink)  
Old March 19th, 2008, 11:53 AM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a MILLION!!!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down list ashu_gupta75 Excel VBA 1 October 15th, 2007 05:52 PM
Drop Down List Code Query rsm42 ASP.NET 1.0 and 1.1 Basics 1 July 4th, 2007 02:22 PM
Access: Drop down list in query newtoaccess Access 1 February 28th, 2006 08:30 AM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM



All times are GMT -4. The time now is 07:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.