Solved

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

Posted on 2013-12-05
3
439 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
[X]
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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

738 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