?
Solved

Open Query From Combo Box In Form

Posted on 2004-09-04
2
Medium Priority
?
218 Views
Last Modified: 2008-02-01
hi

i have querys named:

jan 01
feb 01
mar 01....  ranging all the way to dec 04

I have created a table called "Month (Stats)", with one field called "Month".
In this field i have all the same names as my querys jan 01, feb 02, mar 03, apr 04 etc....

I have also created a form with a combo box that lists all the options from this table.

Is it possible to run the correct query that corrosponds with the same month from this combo box.

also is it possible to have a command button next to this combo box that will open the selected query.

if this isnt clear enough im, sorry, but you guys will probably know what im on about.


Cheers!
0
Comment
Question by:danielgg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 750 total points
ID: 11980446
You can, by doing this:
DoCmd.OpenQuery Me!MeComboBox

in the OnClick event of the command buttoon. This will run the query with the same name as whatever the combo box shows.

I wouldn't recommend though that you do it this way - you'd be better off designing just one query that returns data according to the month you select (it can do this by taking a criteria from the combo box) and just run that one query. That way, you can, for example, create one report that does everything you need rather than designing one report per query (or keep having to change report's record source).
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 11980448

set the row source of your combo box to

Select Distinct [Month] From [Month (stats)]

On the after update of the combo box
Private Sub ComboName_AfterUpdate()
Dim StrQuery as String
strQuery=Me.ComboName.Value
End Sub

on the click of the command button

Private Sub commandbutton_Click()
docmd.SetWarnings False
DoCmd.OpenQuery "" & strQuery &""

docmd.SetWarnings True

End Sub

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question