By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,994 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,994 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.