I have the following code to list query names in Access 2.0's
Immediate Window. Currently, it lists names of all saved queries.
Can you suggest a modification that will result in it listing only
names of queries referencing "tblCorresponde nce"?
Sub ListSavedQrys_C lick ()
'************** *************** *************** *************** *******
' Lists ALL the table names in the immediate window.
'
' This is useful code in many applications. Save it in template &
' refer to it whenever needed. Uses DAO.
'************** *************** *************** *************** *******
On Error GoTo Err_ListSavedQr ys_Click
Dim ThisForm As String
ThisForm = Me.Name
Dim MyQryDef As QueryDef, MyDatabase As Database, I As Integer,
HowManyQrys As Integer
Set MyDatabase = DBEngine.Worksp aces(0).Databas es(0)
Set MyQryDef = MyDatabase.Crea teQueryDef("_Te stOnly")
HowManyQrys = MyDatabase.Quer yDefs.Count
If HowManyQrys > 99 Then
MsgBox "There are " & CStr(HowManyQry s) & " saved queries. The
immediate window will only display 99 lines."
End If
Debug.Print CStr(HowManyQry s)
Exit Sub
For I = 0 To HowManyQrys - 1
Debug.Print MyDatabase.Quer yDefs(I).Name
Next I
MyDatabase.Quer yDefs.Delete "_TestOnly"
Exit_ListSavedQ rys_Click:
Exit Sub
Err_ListSavedQr ys_Click:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub
ListSavedQrys_C lick, CBF on " & ThisForm & "."
k = CRLF & CRLF & Str$(Err) & ": " & QUOTE & Error$ & QUOTE
Message3 = r & k
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume Exit_ListSavedQ rys_Click
End Sub 14 1992
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Like this (air code):
For I = 0 To HowManyQrys - 1
If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then
Debug.Print MyDatabase.Quer yDefs(I).Name
End If
Next I
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQmaCfIechKq OuFEgEQKU/wCg7kkUKXSZHRNE 99HwOP24NToPU0A AoOG8
ETsSGfAs1XfuVvN bTO09vtmB
=q6do
-----END PGP SIGNATURE-----
MLH wrote: I have the following code to list query names in Access 2.0's Immediate Window. Currently, it lists names of all saved queries. Can you suggest a modification that will result in it listing only names of queries referencing "tblCorresponde nce"?
Sub ListSavedQrys_C lick () '************** *************** *************** *************** ******* ' Lists ALL the table names in the immediate window. ' ' This is useful code in many applications. Save it in template & ' refer to it whenever needed. Uses DAO. '************** *************** *************** *************** *******
On Error GoTo Err_ListSavedQr ys_Click Dim ThisForm As String ThisForm = Me.Name
Dim MyQryDef As QueryDef, MyDatabase As Database, I As Integer, HowManyQrys As Integer Set MyDatabase = DBEngine.Worksp aces(0).Databas es(0) Set MyQryDef = MyDatabase.Crea teQueryDef("_Te stOnly") HowManyQrys = MyDatabase.Quer yDefs.Count If HowManyQrys > 99 Then MsgBox "There are " & CStr(HowManyQry s) & " saved queries. The immediate window will only display 99 lines." End If Debug.Print CStr(HowManyQry s) Exit Sub For I = 0 To HowManyQrys - 1 Debug.Print MyDatabase.Quer yDefs(I).Name Next I MyDatabase.Quer yDefs.Delete "_TestOnly"
Exit_ListSavedQ rys_Click: Exit Sub
Err_ListSavedQr ys_Click: Dim r As String, k As String, Message3 As String r = "The following unexpected error occurred in Sub ListSavedQrys_C lick, CBF on " & ThisForm & "." k = CRLF & CRLF & Str$(Err) & ": " & QUOTE & Error$ & QUOTE Message3 = r & k MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " & MY_VERSION$ Resume Exit_ListSavedQ rys_Click
End Sub
<snip> Like this (air code):
For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then Debug.Print MyDatabase.Quer yDefs(I).Name End If Next I
I just knew the above was gonna work when I tried it. But, to my
surprise, it did not. I'm gonna try to find out why.
<snip> Like this (air code):
For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then Debug.Print MyDatabase.Quer yDefs(I).Name End If Next I
Hmmmm??? The problem must be with the .SQL specifier...
I could not even get this to print in the immediate window:
MyString = MyDatabase.Quer yDefs(I).SQL
Debug.Print MyString
MLH wrote: <snip>
Like this (air code):
For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then Debug.Print MyDatabase.Quer yDefs(I).Name End If Next I
Hmmmm??? The problem must be with the .SQL specifier... I could not even get this to print in the immediate window:
MyString = MyDatabase.Quer yDefs(I).SQL Debug.Print MyString
I'm not familiar w/ Access 2.0, so maybe the .SQL property of the
QueryDefs wasn't available in that version. My earliest version was '95.
When you say it's not working, what is it doing instead - error,
nothing? If an error, which one?
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
SQL.Property surely is available in Access 2.0
This wil print out the SQL-string in the Immediate window:
Sub test ()
Set Db = dbEngine(0)(0)
Debug.Print Db.QueryDefs("M yQueryName").SQ L
End Sub
--
Hope this helps
Arno R
"MGFoster" <me@privacy.com > schreef in bericht news:%c******** ***********@new sread1.news.pas .earthlink.net. .. MLH wrote: <snip> Like this (air code):
For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then Debug.Print MyDatabase.Quer yDefs(I).Name End If Next I Hmmmm??? The problem must be with the .SQL specifier... I could not even get this to print in the immediate window: MyString = MyDatabase.Quer yDefs(I).SQL Debug.Print MyString I'm not familiar w/ Access 2.0, so maybe the .SQL property of the QueryDefs wasn't available in that version. My earliest version was '95. When you say it's not working, what is it doing instead - error, nothing? If an error, which one? -- MGFoster:::mgf0 0 <at> earthlink <decimal-point> net Oakland, CA (USA)
On Thu, 21 Apr 2005 02:28:11 GMT, MGFoster <me@privacy.com > wrote: MLH wrote: <snip>
Like this (air code):
For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce")>0 Then Debug.Print MyDatabase.Quer yDefs(I).Name End If Next I
Hmmmm??? The problem must be with the .SQL specifier... I could not even get this to print in the immediate window:
MyString = MyDatabase.Quer yDefs(I).SQL Debug.Print MyString
I'm not familiar w/ Access 2.0, so maybe the .SQL property of the QueryDefs wasn't available in that version. My earliest version was '95.
When you say it's not working, what is it doing instead - error, nothing? If an error, which one?
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxx
Strangely enough, its not returning an error. What does display is the
last value of i on a line by itself.
<snip> SQL.Property surely is available in Access 2.0 This wil print out the SQL-string in the Immediate window: Sub test () Set Db = dbEngine(0)(0) Debug.Print Db.QueryDefs("M yQueryName").SQ L End Sub
Thx for the suggestion. I tried to implement your idea this way:
For I = 0 To HowManyQrys - 1
If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce") > 0
MyName = MyDatabase.Quer yDefs(I).Name
Debug.Print MyDatabase.Quer yDefs(MyName).S QL
End If
Next I
Doesn't work for me. Could it be a timing issue? Hard to imagine.
"MLH" <CR**@NorthStat e.net> schreef in bericht news:8f******** *************** *********@4ax.c om... <snip> SQL.Propert y surely is available in Access 2.0 This wil print out the SQL-string in the Immediate window: Sub test () Set Db = dbEngine(0)(0) Debug.Print Db.QueryDefs("M yQueryName").SQ L End Sub Thx for the suggestion. I tried to implement your idea this way: For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce") > 0 MyName = MyDatabase.Quer yDefs(I).Name Debug.Print MyDatabase.Quer yDefs(MyName).S QL End If Next I Doesn't work for me. Could it be a timing issue? Hard to imagine.
Well the code works for me. Perfectly...
You DID adapt the aircode MGFoster gave you?
You did NOT only use the code as you posted I hope?
Sorry if I ask the obvious ... just trying to be sure.
Arno R
MLH wrote: <snip>
SQL.Propert y surely is available in Access 2.0 This wil print out the SQL-string in the Immediate window: Sub test () Set Db = dbEngine(0)(0) Debug.Print Db.QueryDefs("M yQueryName").SQ L End Sub
Thx for the suggestion. I tried to implement your idea this way: For I = 0 To HowManyQrys - 1 If InStr(MyDatabas e.QueryDefs(I). SQL, "tblCorresponde nce") > 0 MyName = MyDatabase.Quer yDefs(I).Name Debug.Print MyDatabase.Quer yDefs(MyName).S QL End If Next I
Doesn't work for me. Could it be a timing issue? Hard to imagine.
Can one set a reference to ADO in Access 2? I don't know, but if so then
I would do so and then try: (Probably I'd have to hard code the
connection string).
Dim r As ADODB.Recordset
Set r = CurrentProject. Connection.Open Schema(adSchema Views)
With r
Do While Not .EOF
If InStr(.Fields(" VIEW_DEFINITION "), "Classes") <> 0 Then
Debug.Print .Fields("TABLE_ NAME"), .Fields("VIEW_D EFINITION")
End If
.MoveNext
Loop
End With
--
--
Lyle
"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MLH |
last post by:
I have a query, qryAppend30DayOld260ies that attempts to append
records to tblCorrespondence. When run, it can result in any of the
following: appending no records, appending 1 record or appending
many records. Two of the target fields in tblCorrespondence receiving
values in the append operation are and . For
any given VehicleJobID value, I want only ONE record in correspondence
table to have an value of "01". This query blindly appends...
|
by: MLH |
last post by:
I have a table - tblCorrespondence. It houses records
of correspondence initiated here in our office. Records
are appended whenever it is recognized that some type
of outbound letter needs to be created and sent. The
table contains and fields. The
2 fields are updated when the letter is printed, permanently
marking it as having been printed & presumably sent.
At any given moment, there may be a number of unprinted
letters. Whenever...
|
by: MLH |
last post by:
Consider having tblCorrespondence, then copying & pasting
it to tblCorrespondence1 - such that they are identical. Then
consider the following UNION SELECT statement...
SELECT tblCorrespondence.CorrespID, tblCorrespondence.VehicleJobID,
tblCorrespondence.OutDate, tblCorrespondence.OutType,
tblCorrespondence.OutProcessor, tblCorrespondence.InDate,
tblCorrespondence.InRefDate, tblCorrespondence.InType,
tblCorrespondence.InProcessor,...
|
by: MLH |
last post by:
100 Dim db As Database, rst As Recordset
120 Set db = CurrentDb
140 PString = "SELECT qryBatchList.ReadyFor906, qryBatchList.BatchID
FROM qryBatchList WHERE qryBatchList.BatchID=GetCurrentBatchID()"
160 Set rst = db.OpenRecordset(PString, dbOpenDynaset)
At compile time, things are OK. But at run time, line #160
gives rise to an error saying some FN I've used for years
is undefined.
It almost seems like it pukes on some random
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |