Solved

modify vba code to run qry in groups sub folder end to end

Posted on 2013-12-05
3
432 Views
Last Modified: 2013-12-05
Hi Expert's

I have the following vba which needs amending to accommodate the fact my qry's are in a folder called end to end in the Groups plane once u open u Access 2003.


Sub CreateQuery() dim strSQL as string dim qdf as QueryDef strSQL = "SELECT Field1, Field2, Region FROM YourTable WHERE core = '" & me.txtCore & "' ORDER BY [GroupBy]" set qdf = Currentdb.CreateQueryDef("qryMyQuery", strSQL) docmd,OpenQuery "qryMyQuery" end sub
0
Comment
Question by:route217
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39697977
I don't think that what you are asking is possible.  The reason is that those 'groups' in the database window to my understanding are shortcuts, not actual objects.

However if these queries are indeed very similar, you can name them in a way that groups them together.  For example:

Query_01
Query_02
Query_03

etc

(You should give them more descriptive names, but the idea is to name them all with the same prefix and just use consecutive numbers for the last two characters.

If you name them like that, you can run them in order using a loop like this:


Dim I as integer
For I = 1 to 10
    docmd.OpenQuery "Query_" & Format(I, "00")
Next

Open in new window

0
 
LVL 17

Expert Comment

by:JezWalters
ID: 39698015
Is there any chance you could post a sample cut-down (and anonymised) database, to show your problem more clearly?
0
 

Author Comment

by:route217
ID: 39698070
Works...thanks mbizup
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now