If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Drop down or list of queries to select and run in MS Access 2007 form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-15-11, 07:10
Gav Gav is offline
Registered User
 
Join Date: Jun 2011
Posts: 8
Question Drop down or list of queries to select and run in MS Access 2007 form

Hi, I am tyring to work out how I can add a drop down menu to a form which lists all or some of the queries in the db.
Once the the desired query is selected from the drop down then I would like to use a command button to run the query.
Any help would be greatly appreciated.
Thanks,
Gav
Reply With Quote
  #2 (permalink)  
Old 06-15-11, 12:24
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
Put this SQL behind the Row Source of your Drop Down List;

Code:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((MSysObjects.Flags)<>3))
ORDER BY MSysObjects.Name;
Object Type refers to the following

-32764 = Reports
-32768 = Forms
5 = Queries
6 = Tables

You would then have this code behind your button

Code:
If IsNull(Me.List1.Value) = True Then
MsgBox "Please Select a Query from the table!"
Else
DoCmd.OpenQuery Me.List1.Value, , acReadOnly
End If
Reply With Quote
  #3 (permalink)  
Old 06-15-11, 12:53
Gav Gav is offline
Registered User
 
Join Date: Jun 2011
Posts: 8
Thumbs up Thanks!

Thanks Christy,
That works great.
Gav
Reply With Quote
  #4 (permalink)  
Old 06-15-11, 13:08
Gav Gav is offline
Registered User
 
Join Date: Jun 2011
Posts: 8
Question Follow up question

Hi,
I have a follow up question for this. Is it possible to manually enter only some of the queries into the drop down box rather than call all of them as per Christy's answer above.
I would like to separate the queries into groups across a few different drop downs on the form.
Thanks again,
Gav
Reply With Quote
Reply

Tags
dropdown, form

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 On
Pingbacks are On
Refbacks are On