Results 1 to 16 of 16

Thread: Finding system objects - Access 2K [Resolved]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Resolved Finding system objects - Access 2K [Resolved]

    I'm populating a listbox with the names of the tables, queries, forms, etc, in the database. The eventual goal is to be able to make changes in one template database and have a form that will copy the changes to about sixty other db's automatically.
    Anyway, I don't want the (normally) hidden system objects to appear in the listbox. I know I could check Left(tbl.Name, 4) for "Msys", but is there a more OOP way, like checking for a system or hidden property?
    Also, is there a reason that there's no .AddItem property for a standard listbox?
    Thanks.
    VB Code:
    1. Dim ObjAO As AccessObject
    2.       Dim Obj As Object
    3.       Dim s As String
    4.            
    5.       Set Obj = Application.CurrentData
    6.       lstObjects.RowSourceType = "Value List"
    7.      
    8.       For Each ObjAO In Obj.AllTables
    9.             If Not ObjAO.blah = vbSystem Then   'This is where I want a check
    10.                s = s & ObjAO.Name & ";"
    11.             End If
    12.       Next
    13.      
    14.       lstObjects.RowSource = s
    Last edited by salvelinus; Jul 31st, 2005 at 11:01 AM.
    Tengo mas preguntas que contestas

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Finding system objects - Access 2K

    To the best of my knowledge I think the only way you can determine the system tables is through left(tablename,4) = "Msys" method that you have mentioned...

    Don't have Access 2000 installed, but could of sworn that .Additem was introduced in this version.. it's definately not in Access 97
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K

    Thanks. There's an .AddItem method for a commandbar listbox in 2000, but apparently not for a toolbox one.
    Another odd thing is that you have to use .CurrentData to iterate tables & queries with a For Each statement, but .CurrentProject for forms & reports.
    Tengo mas preguntas que contestas

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Finding system objects - Access 2K

    That'll be because .CurrentData refers to uncodable items such as Tables and Queries.. And .CurrentProject Refers to codable items such as Forms, Reports and modules.

    You could also use the Document Property for all objects
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Finding system objects - Access 2K

    You can run a query against the system table.
    VB Code:
    1. "SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') " & _
    2. "AND (Left$([Name],4) <> 'Msys') AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;"
    This will retrieve all the user Tables in the DB.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K

    Thanks both, that's usefull info I didn't know. The MSysObjects table is nice to know.
    Tengo mas preguntas que contestas

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K

    Quote Originally Posted by dannymking
    That'll be because .CurrentData refers to uncodable items such as Tables and Queries.. And .CurrentProject Refers to codable items such as Forms, Reports and modules.

    You could also use the Document Property for all objects
    Well, you'd think there'd be one property that could reference all. Not familiar with the Document property, will look that up Monday.
    Tengo mas preguntas que contestas

  8. #8
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Finding system objects - Access 2K [Resolved]

    Document propert is actually an element of DAO..

    VB Code:
    1. Sub GetTableNames()
    2.     Dim Db As DAO.Database
    3.     Dim Doc As DAO.Document
    4.     'Initialize the DAO Database by setting it to the current database
    5.     Set Db = CurrentDb
    6.     'Now loop around the number of tables found within the database, because we are using the documents collection
    7.     'we do not need to set an upper and lower limit
    8.     For Each Doc In Db.Containers!Tables.Documents
    9.         'Display each tablename to the immediate window
    10.         Debug.Print Doc.Name
    11.     Next Doc
    12.     'Close the reference
    13.     Set Db = Nothing
    14. End Sub

    Subsitute Tables for Forms, Modules, Reports or Queries
    Last edited by dannymking; Jul 31st, 2005 at 12:12 PM. Reason: More explanation
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Finding system objects - Access 2K [Resolved]

    Ok, got the rest of the objects...
    VB Code:
    1. 'Queries:
    2. "SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') " & _
    3. "AND (MSysObjects.Type)=5 ORDER BY MSysObjects.Name;"
    4.  
    5. 'Reports:
    6. "SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') " & _
    7. "AND (MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name;"
    8.  
    9. 'Forms:
    10. "SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') " & _
    11. "AND (MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name;"
    12.  
    13. 'Modules:
    14. "SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') " & _
    15. "AND (MSysObjects.Type)= -32761 ORDER BY MSysObjects.Name;"
    16.  
    17. 'Macros:
    18. "SELECT MSysObjects.Name FROM MsysObjects WHERE  (Left([name], 1) <>'~') " & _
    19. "AND (MSysObjects.Type)= -32766 ORDER BY MSysObjects.Name;"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K [Resolved]

    Thanks, but who the heck ever heard of (MSysObjects.Type)= -32766?
    It would just be a lot simpler if MS gave this stuff a boolean System property.
    But I do appreciate your help. Thanks.
    Tengo mas preguntas que contestas

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Finding system objects - Access 2K [Resolved]

    Well the Type is Access' constant value for a Form (-32768). If you have ever browsed through the system tables you will see allot of records with field values like this. Its just the way Access does it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K [Resolved]

    I suppose it would be helpful to do that, but it still seems like there ought to be a property to check. If I see a value like 32768 I start thinking of the limit to integer values, 32767.
    Tengo mas preguntas que contestas

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Finding system objects - Access 2K [Resolved]

    You could also do this by opening the DB Schema via ADOX but it will be more work and code since you will have to make a few calls to the db. One for the tables, then one for its field types. Then repeat for each db object type.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K [Resolved]

    Aaaghh! That's my whole point. There ought to be a simple object property to check, like .Visible. MS, grrr...
    Tengo mas preguntas que contestas

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Finding system objects - Access 2K [Resolved]

    Maybe you could execute the menu items to do a Tools > Anaylze > Documenter with the DoCmd.DoMenuItem ?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Finding system objects - Access 2K [Resolved]

    I'm fine with gritting my teeth & muttering "G-D MS". But thanks.
    Tengo mas preguntas que contestas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width