Buttom/Combo Box To List Queries in Access Runtime

Posted on 2014-03-25
Last Modified: 2014-03-25

I was wondering if someone could help.

We currently have an Access 2007 database, which has a number of reports and forms contained with in. Full blown Access 2007 users get a Navigation pane (see attachments) on the left of the 'front screen' where if the expand it, lists a number (30+) of pre-prepared queries. We need to deploy this database to a number of other users, and would like to use MS Access Runtime, as 99% of the functionality we need is available, and it's free vs £400+ for full blown access! However the Navigation bar isn't available in Access Runtime, so I'd like to add a button or combo box to the fornt screen, which would list all the queries available, and allow Access Runtime users to select then run them.

Is this possible? Does anyone have the code? I've had a quick look online, and seen a few posts with similar questions, but I can't seem to get them to work. Not sure if its because the posts are for a newer version of Access (we're using 2007), or if I'm getting something wrong! My Access programmming is quite basic, I'm usually more a PHP & VBScript person.

Any help greatly appreciated!

Question by:bjblackmore
  • 5
  • 3
  • 2
LVL 27

Accepted Solution

MacroShadow earned 500 total points
ID: 39952907
Create a list box, set it's row source to:
SELECT [Name] FROM MsysObjects
WHERE (([Type] = 5) AND ([Name] Not Like "~*") AND ([Name] Not Like "MSys*"))
ORDER BY [Name];

Open in new window

That will list all the queries in the database, then to run the query do something like this:
DoCmd.OpenQuery Me.ListBoxName

Open in new window


Author Comment

ID: 39952919
Thanks for the reply.

When you say se thte row source, is that just clicking on the 3 little dots '...' in the 'Data' options (see below pic)? When I click that I get an 'Edit List Items' dialogue box. If I enter the code supplied in there, it just displays that code as 3 options in the list box?

Author Comment

ID: 39952933
Ah, I had to change the Row Source Type to Table/Query and change it to SQL view! Think I have it now....
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39952936
Personally, I don't think you really want to expose "ALL" of the queries to users of the application.  The way I do this is I create a table which contains the names of all of the queries I want them to be able to run, and a description.

I display that table to them in a listbox so they can see the description and have a button next to the list box that opens the query using.

Docmd.OpenQuery me.lst_Queries,  , acReadOnly

Author Comment

ID: 39952997
It depends, the people who have full blown Access just use the Nav Pane, and that appears to have access to/shows all the queries. The database wasn't designed by me or even IT, some previous user in the department that I'm modifying this for, who left long ago. We now have said department asking us to make modifications to it. I really want to spend as little time as possible doing it. If they want to maintain/edit the database properly, they need to do it as a project and get a programmer in, rather than a helpdesk ticket!

Author Closing Comment

ID: 39953000
Perfect, just what I was looking for!
LVL 27

Expert Comment

ID: 39953052
You're welcome, glad to help.
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39953235
"the people who have full blown Access just use the Nav Pane"

is a bad idea.  In general, you should not provide your database users access to the navigation pane.  It allows them to directly modify data in your tables without using forms.  It also allows them to modify the queries in ways that will take you forever to figure out.

Author Comment

ID: 39953336
I know, it is a concern, however as I said, the database is not our responsibility, it wasn't designed by us, and isn't managed/administered by us, we don't have the man power or knowledge with in the department to be able to program these things.

If the department wants better control over the database, they will need to create a small project, provide a budget for a contractor with a scope of work. And having spoken with them today, they don't even know what they want to do, who they want to give access, or what access they want to provide! Sadly this is the trouble with high turn over, knowledge is lost, and the people left to take over have no idea!

What I have done, is taken your advice and modified the double click command with "acReadOnly"

So it now runs:
Private Sub ListQueries_DblClick(Cancel As Integer)
DoCmd.OpenQuery Me.ListQueries, , acReadOnly
End Sub

Open in new window

This will stop people modifying data via a query. However the department haven't approved this yet, they may actually want to modify data via a query. I will suggest to them they shouldn't, but doesn't mean they will listen!

If I could re-open the question, I'd re-allocate some points for the above comment, but I can't see if that's possible?
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39953429
don't worry about the points

I just wanted to make sure you understood the pitfalls of allowing anyone to have direct access to data tables and queries.

One way to mitigate that, although only limited, is to make sure everyone has their own copy of the application on their own desktop, and are linked to the backend database.  That way they will not be able to corrupt the main database that contains the queries in their original form.

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Combobox row source 2 20
Batch Export Reports (with multiple parameters) As PDF 2 21
Teradata converting character to integer 2 16
Switch 5 16
Creating and Managing Databases with phpMyAdmin in cPanel.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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 …
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…

773 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