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
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
  • 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....
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

LVL 48

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 48

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 48

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

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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