473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Can I label queries so the can be copied with VBA? Confused!

I have two versions of a database front end and want to be able to use
docmd.copy (or some other method) to move a bunch of queries.

I was able to use the '.tag' property to of forms and reports to move
them using code. For example, first I put the word "Special" in the
..tag property of my reports (or forms), then I use the following
procedure:

Sub CopyReps()

Dim db As Database
Dim con As Container
Dim doc As Document
Dim rpt As Report
Dim strReportName As String

Set db = CurrentDb
Set con = db.Containers("Reports")

For Each doc In con.Documents
strReportName = doc.Name
DoCmd.OpenReport strReportName, acViewDesign
Set rpt = Reports(strReportName)
If rpt.Tag = "Special" Then
DoCmd.CopyObject "DestinationDatabase.mdb", strReportName ,
acReport, strReportName
End If
DoCmd.Close acReport, strReportName
Set rpt = Nothing
Next doc
End Sub

I know this isn't very elegant, but it seems to work. Is a way to do
the same with queries. I have a dozen or so 'special 'queries buried
in the 600 some odd queries in my application and would love to be
able to move them in one fell swoop whenever I update my front end.

Is there some property of queries I can tag so that my code can find
and move them? Should I take a different strategy? For example, is
there a way to use code to address the members of a 'Group' in the
database window?

Thanks in advance for the help!
Jim
Nov 13 '05 #1
1 1417
You can create custom properties for QueryDefs, so you can give them a "Tag"
with CreateProperty().

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"j.mandala" <ma*****@rci.rutgers.edu> wrote in message
news:6c**************************@posting.google.c om...
I have two versions of a database front end and want to be able to use
docmd.copy (or some other method) to move a bunch of queries.

I was able to use the '.tag' property to of forms and reports to move
them using code. For example, first I put the word "Special" in the
.tag property of my reports (or forms), then I use the following
procedure:

Sub CopyReps()

Dim db As Database
Dim con As Container
Dim doc As Document
Dim rpt As Report
Dim strReportName As String

Set db = CurrentDb
Set con = db.Containers("Reports")

For Each doc In con.Documents
strReportName = doc.Name
DoCmd.OpenReport strReportName, acViewDesign
Set rpt = Reports(strReportName)
If rpt.Tag = "Special" Then
DoCmd.CopyObject "DestinationDatabase.mdb", strReportName ,
acReport, strReportName
End If
DoCmd.Close acReport, strReportName
Set rpt = Nothing
Next doc
End Sub

I know this isn't very elegant, but it seems to work. Is a way to do
the same with queries. I have a dozen or so 'special 'queries buried
in the 600 some odd queries in my application and would love to be
able to move them in one fell swoop whenever I update my front end.

Is there some property of queries I can tag so that my code can find
and move them? Should I take a different strategy? For example, is
there a way to use code to address the members of a 'Group' in the
database window?

Thanks in advance for the help!
Jim

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Marco Alting | last post by:
Hi, I'm still confused about my queries, I want to do something is ASP that is easily done in Access. I'll post the Access queries below as a reference. The main idea is that the queries depend...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
3
by: RC | last post by:
I am using docmd.printout to send Reports (formatted as labels) to a barcode label printer. I need to collate the labels so that I print lable 1 twice, then label 2 twice, then label 3 twice, etc....
5
by: KitKat | last post by:
I've got two queries; one is a modification of an older query; the other I created from scratch. The old one is about 5 copies down the road from something that has been expandable when I'm in...
8
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
3
by: peter.meth | last post by:
Hi All, I am making a file manager type of application and am trying to duplicate Windows Explorer's behaviour when copying files; ie, display a second form with the copy files animation. As it...
3
by: KenMacksey | last post by:
Hi I am running VB6 on a pentium 4 and Win XP pro. I wrote a small program to copy files to a memory card or mp3 player etc in a specific order or a random order instead of the windows default...
2
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, I have a Label on a Windows form (Version 1.1.4322) and while I iterate recursively through a method I want to show the name of the current file being copied to another directory. The...
4
by: Henrootje | last post by:
I have a REPORT with in it a subFORM Now I have this label (lblMonth) that I want to change. How should I do this? What would be the proper event to do this? The lblMonth should contain the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.