Der Community
I have a database with several forms, tables, queries and reports. I am actually editing the database and would like to delete some of the queries. Before I delete a query I would like to know if this query is related to another data (form, report) in the database in order not to delete a related query.
Can somebody tell me how and if I can quickly find this out?
Thanks a lot
Mike
Mike,
Here is a more stable version of the Analyse Program.
Let me know progress
Phil
23 2237
Firstly, I suggest that whenever you create a new object (and particularly a query) you either right click on the query in the Nave Pane, and under View Properties, enter what the query is for.
Alternatively with the query in design view, if you left click in the grey area, you get the query properties and you can enter the Description. (Remember to press the return key after you have entered the description, else it won't be saved).
Anyway, that's for the future.
I have a rather buggy program that will help, but will see if I can sort out the problems, and send it later.
Phil
ADezii 8,834
Recognized Expert Expert - The Method that I use is to generate Dependency Information regarding a specific Query, or all Queries. In this Demo I use the Order Details Extended Query of the Northwind Sample Datbase.
- Base Code:
- Dim AccObj As AccessObject
-
Dim dpdInfo As DependencyInfo
-
Dim intCtr As Integer
-
Dim strQueryName As String
-
-
strQueryName = "Order Details Extended"
-
-
'Must enable the Track name AutoCorrect in order to update the
-
'Deependency information for all of the Objects in the Database:
-
Application.SetOption "Track Name AutoCorrect Info", 1
-
-
Set AccObj = Application.CurrentData.AllQueries(strQueryName)
-
Debug.Print "QUERY Name: " & strQueryName
-
Debug.Print "---------------------------------------------------------------------------------"
-
Debug.Print "[Fields: " & fGenerateFieldList(strQueryName) & "]"
-
-
Set dpdInfo = AccObj.GetDependencyInfo
-
-
Debug.Print " |-- Number of Dependencies : " & dpdInfo.Dependencies.Count
-
-
For intCtr = 0 To dpdInfo.Dependencies.Count - 1
-
Debug.Print " |-- Depends on: " & dpdInfo.Dependencies(intCtr).FullName
-
Debug.Print " |-- " & IIf(dpdInfo.Dependencies(intCtr).Type = acQuery, "Query", "Table") & _
-
" - " & dpdInfo.Dependencies(intCtr).DateCreated
-
Next
-
Debug.Print "---------------------------------------------------------------------------------"
- Required Function:
- Public Function fGenerateFieldList(strQueryName As String) As Variant
-
On Error Resume Next
-
Dim qdf As DAO.QueryDef
-
Dim intFldCtr As Integer
-
Dim varBuild As Variant
-
-
Set qdf = CurrentDb.QueryDefs(strQueryName)
-
-
For intFldCtr = 0 To qdf.Fields.Count - 1
-
If InStr(qdf.SQL, qdf.Fields(intFldCtr).Name) > 0 Then
-
varBuild = varBuild & qdf.Fields(intFldCtr).Name & ","
-
End If
-
Next
-
-
varBuild = Left(varBuild, Len(varBuild) - 1)
-
-
fGenerateFieldList = varBuild
-
End Function
- OUTPUT for the Order Details Extended Query:
- QUERY Name: Order Details Extended
-
---------------------------------------------------------------------------------
-
[Fields: ID,Quantity,Unit Price,Discount,Status ID,Extended Price,Status Name]
-
|-- Number of Dependencies : 2
-
|-- Depends on: Order Details
-
|-- Table - 12/5/2016 8:14:48 PM
-
|-- Depends on: Order Details Status
-
|-- Table - 12/5/2016 8:14:49 PM
-
---------------------------------------------------------------------------------
- Hope this works for you.
ADezii 8,834
Recognized Expert Expert - Here are two additional points that I wish to mention:
- The Example that I gave you displays the Object(s) that the Query depends on.
- In order to display the Object(s) that depend on the Query, you must use the Dependants, NOT Dependencies, Property of the AccessObject Object.
- Hope this helps.
- I do realize that this is a little confusing (LOL).
Mike
This is passably OK.
First select the database you want to analyse (I strongly suggest a copy)
Then press "Analyse Database" (The Analyse modules has yet to be written)
Click on an item in the "Master Record Set" and this will show where the object is used, and what objects it uses.
If you double click the red items in the 2 right hand subforms, you make those the master record set.
Phil
ADezii 8,834
Recognized Expert Expert
I created a Demo for you that will list both Dependent and Dependant Information for a specific Query. Simply click the Command Button, the results will be displayed in the Debug Window.
Dear all
Thank you for your help. Somehow it did not work.
@Phil: I could not open my database in your tool. Only a database that was already there from you. But on this database I had no access since it is on your computer.
@ADezii: I only could push on a button called "Guess which button to click" but nothing more happened...
Mike
ADezii 8,834
Recognized Expert Expert
Something did happen - as indicated in Post# 6 the results will be displayed in the Immediate Window. I will make a simple revision to the Code to make the results more obvious when I get a chance.
Dear ADezii
Thanks for your work. I am really very happy about it. But I would need a sample as I do not understand the whole VBA-Code instructions that you mentionned in your earlier posts...
Mike
Mike,
Here is a more stable version of the Analyse Program.
Let me know progress
Phil
Thanks, Phil
I will try it this Wednesday and give a feedback!
Mike
ADezii 8,834
Recognized Expert Expert
This should clarify things for you.
Dear Phil and ADezii
I am really sorry, but maybe I am a bit dull. But how can I use your Files? I tried but somehow it does not work. Do I first have to open up my database and then your file or can I somehow include my database into your files?
Thank you!!!!
Mike
I'll let ADezii speak for himself.
With the Analyse 2017 Db, all you should do is open Analyse 2017 Db, Open a form called "SetUpRelations". This will open up Explorer where you select the database you want to analyse.
Alternatively, use the "Select Database" Button on the "SetUpRelations" Form to select your database that you want to analyse.
You should then start seeing data in the form. from your Db.
Then press the "Analyse Database" Button to get further information.
Let me know of your progress.
Phil
Dear Phil
Thank you, now it worked! The connections of my queries were shown in your database. For the connections of forms, it did not work properly, I tried this as well. But it did not show me the connections even though there were some connections.
Thanks a lot for helping me!!!
Mike
What do you mean by "connection" between forms? It should show any subtitles. Am out all day, but will check this evening.
Phil
Dear Phil
With connections I mean the "relationships" (objects used in... and is used in...)
With the queries it worked but with the forms it did not. As I only needed it for queries, that is not a problem for me...
Thank you!
Mike
Mike. It should be working
After you press the "Analyse Database" button, do you see all the Forms & Reports in your DB being opened up.
Here are a couple of pictures. I the first I have selected the form "Investments in the left hand panel, and in the yellow panel it lists 20 subforms, combo boxes & list boxes (you need the scroll bar to see all 20)
The second image shows what happens after double clicking the SubCodes in the Yellow Panel
This shows where SubCodes is used (Green Panel - Obviously in the Investment Form, but also in the Indices Form)
It also says there is Combo Box with the Rowsource and the Subform's RecordSource.
If you double Click the Name on the Navy Master object panel, you see the object in design view (it is not working for forms on your version as there are 2 lines of code missing, but it should work for reports & queries)
If you want, in the Module "ZZSetUpRElations", In the Function "ShowObject", add the missing lines immediately below Case -32768
It should look like this -
Case -32768 'Form
-
apiSetForegroundWindow AccApp.hWndAccessApp
-
apiShowWindow AccApp.hWndAccessApp, SW_NORMAL
-
AccApp.DoCmd.OpenForm Frm!ObjectName, acDesign
-
-
Case -32764 'Reports
-
apiSetForegroundWindow AccApp.hWndAccessApp
-
apiShowWindow AccApp.hWndAccessApp, SW_NORMAL
-
AccApp.DoCmd.OpenReport Frm!ObjectName, acDesign
-
Phil
ADezii 8,834
Recognized Expert Expert @MikeMikeCH:
Didn't want you to think that I left you stranded. Phil's example and Attachment is much, much better than the limited solution that I came up with. Good Luck with your Project.
Der ADezii
Thanks a lot!!
Mike
Dear Phil
Thanks for your further information. On my computer I can Analyse the database and find my forms, queries and tables.
It only shows me the relationships (Objects used in... / Is used in...) for tables and queries but not for forms. When I chose a form, the whole yellow and green part stays clear although the forms are used in other objects or at least use other objects... This is ok for me because I do not need it for my forms.
If I can give you further information about it, please let me know!
Thanks a lot!!!!!!!!
Mike
Very Odd.
The only way I have got it to fail is if there is something the matter with the database being analysed (e.g. a compile error or missing table etc)
There should be 2 Access windows open and it is worth checking there is no error message in the database being analysed. Also, move the database being analysed around and see if you can see the rainbow coloured progress meter in the "Analyse 2017" database.
Phil
Dear Phil
Thank you for your answer. I found out the solution. I had to rechose the database and again analyse it. Then it worked :-)
Thank you so much!
Mike
I really want to mention that the tool of Phil is really amazing! Thank you!!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Anibal Acosta |
last post by:
for example I need to do...:
Dim drow as DataRow
Dim myNewTable as New DataTable
For each drow in myTable.Select("mySelectString")
if drow(0) = "something" then
' --- Here I want to add...
|
by: Stan |
last post by:
My webserver calls a component on another server through DCOM, the component
goes to SQL, SQL raises the exception and here is what the client gets:
"Cannot find member name...
|
by: KnightWolfJK |
last post by:
I'm working with a form and need some help customizing the results of
a find query. I dug thru the archives and used this post...
|
by: yatharth |
last post by:
I have Query related to RCW(Runtime Callable Wrapper), how to use
unmanaged code through managed C# and how to interact with COM
component by
C#. Actually I have to use C/C++/VC++ developed API in...
|
by: info |
last post by:
i researched for a while on the net and found that more people have
this problem, but could not get an answer.
i am very new to MySql.
linux - feudora
i log into mysql using "root"
when...
|
by: Sorin Marin |
last post by:
Hi Experts,
I have some Oracle views linked in an Access database ¬ this is the good part. Now I try to link to an Access query from other database (still Access) but I have no clue how.
I'm a bit...
|
by: Carl |
last post by:
Hi
Is it possible to find out if another process is using a paticular file
(xml)? There does not seem to be anything useful in the File och Filestream
class for this purpose.
regards
Carl
|
by: Luqman |
last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with
the parameters, and its connected with DetailView Control.
When I try to Insert through DetailView Control, Illegal...
|
by: teddysnips |
last post by:
My clients have asked me to maintain a database that was developed in-
house. It's pretty good, considering the developer isn't a
"programmer".
The first thing they want me to do is to split it...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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,...
|
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...
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |