Solved

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

Posted on 2013-12-05
3
436 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

919 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

18 Experts available now in Live!

Get 1:1 Help Now