Query System Objects and Description

psulions83

Board Regular
Joined
Nov 16, 2015
Messages
126
Hi,

Is there a way to add the description from each item in the below queries to return the description from the properties menu for each item?


Code:
[B]Queries[/B][COLOR=#000000][FONT=Verdana]:[/FONT][/COLOR][INDENT]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
(MSysObjects.Type)=5 ORDER BY MSysObjects.Name;[/INDENT][COLOR=#000000][FONT=Verdana][B]Tables[/B]:[/FONT][/COLOR]
[INDENT]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
(Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;[/INDENT][COLOR=#000000][FONT=Verdana][B]Reports[/B]:[/FONT][/COLOR]
[INDENT]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
(MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name;[/INDENT][COLOR=#000000][FONT=Verdana][B]Modules[/B]:[/FONT][/COLOR]
[INDENT]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
(MSysObjects.Type)= -32761 ORDER BY MSysObjects.Name;[/INDENT][COLOR=#000000][FONT=Verdana][B]Macros[/B]:[/FONT][/COLOR]
[INDENT]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND  [/INDENT][COLOR=#000000][FONT=Verdana](MSysObjects.Type)= -32766 ORDER BY MSysObjects.Name;[/FONT][/COLOR]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
AFAIK You cant get the properties without using a User defined function. If you insert the following function into a model and then call from a query it should work:

Code:
Public Function TableDescr(stTableName As String) As String
On Error Resume Next
TableDescr = CurrentDb.TableDefs(stTableName).Properties("Description").Value
End Function

call as follows:

Code:
[FONT=Verdana][B]Tables[/B]:[/FONT]SELECT MSysObjects.Name, [COLOR=#ff0000]TableDescr([Name]) AS Description[/COLOR]  FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
(Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;
 
Upvote 0
Stumac,

Thank you... this worked for the tables. Can this be modified to call the same things for queries and macros?
 
Upvote 0
The first worked but I am not sure if you can do the same thing with Macros? I tried running with a S and no S and got same results in Macro(s).

Code:
Public Function QueryDescr(stQueryName As String) As StringOn Error Resume Next
QueryDescr = CurrentDb.QueryDefs(stQueryName).Properties("Description").Value
End Function

SELECT MSysObjects.Name, QueryDescr([Name]) AS Description
FROM MsysObjects 
WHERE (Left$([Name],1)<>"~") AND 
(MSysObjects.Type)=5 
ORDER BY MSysObjects.Name;






Public Function MacroDescr(stMacroName As String) As String
On Error Resume Next
MacroDescr = CurrentDb.MacroDefs(stMacroName).Properties("Description").Value
End Function

SELECT MSysObjects.Name, MacroDescr([Name]) AS Description
FROM MsysObjects 
WHERE (Left$([Name],1)<>"~") AND 
(MSysObjects.Type)=-32766
ORDER BY MSysObjects.Name;
 
Upvote 0
The following should work for Macros:

Code:
Public Function MacroDesc(stMacroName As String)
On Error Resume Next
MacroDesc = CurrentDb.Containers("Scripts").Documents(stMacroName).Properties("Description")
End Function
 
Last edited:
Upvote 0
Thanks that works. Is there a specific part missing below for modules? I get the query to come back but it doesnt have the description.

Code:
Public Function ModuleDesc(stModuleName As String)On Error Resume Next
ModuleDesc = CurrentDb.Containers("Scripts").Documents(stModuleName).Properties("Description")
End Function

SELECT MSysObjects.Name, ModuleDesc([Name]) AS Description
FROM MsysObjects
WHERE (Left$([Name],1)<>"~") AND
(Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=-32761
ORDER BY MSysObjects.Name;
 
Upvote 0
You are looking at Macros modules would not show under scripts.

change Scripts to modules:

Code:
ModuleDesc = CurrentDb.Containers("Modules").Documents(stModuleName).Properties("Description")
 
Upvote 0
No worries - apologies, I had only seen the first part of your original Question when I answered, could have saved a lot of going back in forward if I had paid more attention! :oops:
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top