Solved

Open Query From Combo Box In Form

Posted on 2004-09-04
2
215 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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.

733 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