A Microsoft Office (Excel, Word) forum. OfficeFrustration

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   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Create a list of queries to include in a drop-down menu



 
 
Thread Tools Display Modes
  #11  
Old June 10th, 2008, 01:52 PM posted to microsoft.public.access.forms
sverre
external usenet poster
 
Posts: 53
Default Create a list of queries to include in a drop-down menu

Great works fine! Many thanks Douglas!

The advantage with using select queries was that users easily can copy paste
to Excel, but maybe you can do that in reports aswell?

For my curiousity - are you sql and vba-programmer by profession?
You write code that for me is very advanced and very exact. If I would like
to learn
the basics of access (except for writing select queries) - could you
recommend training courses or a book? I have a pdf-book called Access 2002
Bible.

Many thanks again,
Sverre


"Douglas J. Steele" wrote:

In my sample code, "cboQueries" is assumed to be the name of the combo box
containing the names of the queries.

If your combo box is called something different, use your name.

As to alternatives to running queries, yes, running a report instead would
be better in my opinion.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"sverre" wrote in message
...
I think the error can be "cboQueries". Keyword not found says the help
function when I press F1. Do I need to add something like an add-in?
Sverre

"Douglas J. Steele" wrote:

I gave you the code you need to put in the AfterUpdate event of the combo
box for which I previously gave your the RowSource. The AfterUpdate event
fires once the user has made a selection in the combo box.

I still think it's unusual to have users run Select queries.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"sverre" wrote in message
...
Hi Douglas

Sorry, I have expressed myself unclear. The art of explaining is
sometimes
difficult. The queries are select queries and the reason to create the
drop
down list is that I want the users to have the possibility to run some
of
all
select queries in a menu - there are a lot of queries out of there
interest
not to be included. So my thought was to allow users to run any of the
queries in the list by activating it in the list. I have added the SQL
you
gave me in your first response in a combo box as a "row source", but I
would
like to "connect" each query-name in the list to make Access run the
query
itself and display the result when the user select the name of select
query.

I am not very familiar with forms and buttons so maybe I am moving in
the
wrong direction to create the above solution? With this information
above -
can I use your vba code in previous answer and if yes! where in the
properties do I put it?

Hope I have explained myself more clear now!

Regards
Sverre

"Douglas J. Steele" wrote:

Depends what you mean by "run the queries".

If they're Action queries (INSERT INTO, UPDATE, DELETE), then you can
use
code like:

Private Sub cboQueries_AfterUpdate

CurrentDb.QueryDefs(Me.cboQueries).Execute

End Sub

If they're Select queries, I don't really understand why you'd want
your
users to run them, but you can use code like:

Private Sub cboQueries_AfterUpdate

DoCmd.OpenQuery Me.cboQueries

End Sub

Using the OpenQuery method, you can make the query Read-Only if you
want.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"sverre" wrote in message
...
Thank you Douglas,
Can I use this to allow users to run the queries in the list from a
drop-down menu?
regards
Sverre

"Douglas J. Steele" wrote:

The following SQL will list all queries in your database:

SELECT Name
FROM MSysObjects
WHERE Type = 5
ORDER BY Name

Can you put an appropriate WHERE clause on there to limit it to
only
those
of interest to you?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"sverre" wrote in message
...
Hi

I would like to create a list of queries (not all ) to include
this
list
in
a drop-down menu. But I cannot find where I start creating the
list.

Could someone help me!

Best regards

Sverre












  #12  
Old June 10th, 2008, 03:12 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Create a list of queries to include in a drop-down menu

"sverre" wrote in message
...
Great works fine! Many thanks Douglas!

The advantage with using select queries was that users easily can copy
paste
to Excel, but maybe you can do that in reports aswell?


No, you can't. Reports aren't interactive. If the intent is to export to
Excel, why not do the "heavy lifting" for them, and use TransferSpreadsheet
to put the data into Excel?

For my curiousity - are you sql and vba-programmer by profession?
You write code that for me is very advanced and very exact. If I would
like
to learn
the basics of access (except for writing select queries) - could you
recommend training courses or a book? I have a pdf-book called Access 2002
Bible.


To be honest, I hardly program anymore (and I'm working mostly with
mainframe computers at the moment!). However, I've long had a interest in
educating people and helping to improve their programming style. I wrote the
"Access Answers" column for more than two and a half years (see
http://www.accessmvp.com/DJSteele/SmartAccess.html for a free archive of my
columns)

For a great list of resources to help you learn Access, see what Jeff Conrad
has at http://www.accessmvp.com/JConrad/acc...resources.html


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.