Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open Query From Combo Box In Form

Posted on 2004-09-04
2
Medium Priority
?
221 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

610 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