Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-12-05
3
Medium Priority
?
442 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

927 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