Question Display object name

gcarpenter

Registered User.
Local time
Today, 13:26
Joined
Oct 21, 2013
Messages
68
I have the follow code tha tells me when an object is laoded, I cannot get it to display the name of the form or report or whatever object isloaded. any help would be appreciated.

Private Sub Command51_Click()
Dim aob As AccessObject
Dim obj As AccessObject
With CurrentData
' "Tables"
For Each aob In .AllTables
If aob.IsLoaded Then
MsgBox " Tables are Open", vbOKOnly, "Table open in Database"
End If
Next aob
' "Queries"
For Each aob In .AllQueries
If aob.IsLoaded Then
MsgBox " Queries are Open", vbOKOnly, "Query open in database"
End If
Next aob
End With

With CurrentProject
' "Forms"
For Each aob In .AllForms
If aob.IsLoaded Then
MsgBox "Forms are open", vbOKOnly, "Form open in database"
End If
Next aob

' "Reports"
For Each aob In .AllReports
If aob.IsLoaded Then
MsgBox "Reports are open", vbOKOnly, "Report open in database"
End If
Next aob
' "Pages"
For Each aob In .AllDataAccessPages
If aob.IsLoaded Then
MsgBox "DataAccessPages are open", vbOKOnly, "DataAccessPage open in database"
End If
Next aob
' "Macros"
For Each aob In .AllMacros
If aob.IsLoaded Then
MsgBox "Macros are open", vbOKOnly, "Macro open in database"
End If
Next aob
' "Modules"
For Each aob In .AllModules
If aob.IsLoaded Then
MsgBox "Modules are open", vbOKOnly, "Module open in database"
End If
Next aob
End With
End Sub
 
Does

aob.Name

work?
 
No, compile error, invalid use of property. That is what is confusing me. I thought that property could be used in that context.
 
pbaldy, I figured it out, I posted the code for anyone to use. This allows you to create a command button and click it to see what is handing out there open in your database, it displays the name of what the open Accessobject is.

Private Sub Command51_Click()
Dim aob As AccessObject
Dim obj As AccessObject

With CurrentData
' "Tables"
For Each aob In .AllTables
If aob.IsLoaded Then
MsgBox " Tables are Open", vbOKOnly, aob.NAME
End If
Next aob
' "Queries"
For Each aob In .AllQueries
If aob.IsLoaded Then
MsgBox " Queries are Open", vbOKOnly, aob.NAME
End If
Next aob
End With

With CurrentProject
' "Forms"
For Each aob In .AllForms
If aob.IsLoaded Then
MsgBox "Forms are open", vbOKOnly, aob.NAME
End If
Next aob

' "Reports"
For Each aob In .AllReports
If aob.IsLoaded Then
MsgBox "Reports are open", vbOKOnly, aob.NAME
End If
Next aob
' "Pages"
For Each aob In .AllDataAccessPages
If aob.IsLoaded Then
MsgBox "DataAccessPages are open", vbOKOnly, aob.NAME
End If
Next aob
' "Macros"
For Each aob In .AllMacros
If aob.IsLoaded Then
MsgBox "Macros are open", vbOKOnly, aob.NAME
End If
Next aob
' "Modules"
For Each aob In .AllModules
If aob.IsLoaded Then
MsgBox "Modules are open", vbOKOnly, aob.NAME
End If
Next aob
End With
End Sub
 
I thought it should work. Glad you got it sorted out.
 
Thank you, I was missing the fact that it could be used to replace the title of the message box. You jogged my memory. Once again thanks.
 
No problem. It could have been used in the message too, like:

MsgBox "The Form named " & aob.NAME & " is open", vbOKOnly
 

Users who are viewing this thread

Back
Top Bottom