Results 1 to 5 of 5

Thread: [Access] Reading Custom properties

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Location
    LI, NY
    Posts
    4

    [Access] Reading Custom properties

    Not sure if this belongs in this forum or VB.Net. Please feel free to move it if necessary.

    I am new to VB.Net and I'm trying to build an app that will read custom properties set in an accdb file. Basically, I'm trying to build a Front End updater (Yes I know there are others already built, but they don't work the way I want).

    I've got most of the code set up, but my sticking point is how to read the custom properties. If anyone can point me in the right direction, I would appreciate it.

    Scott<>

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

    Re: [Access] Reading Custom properties

    So you mean customer properties as in properties you wrote in your class file(s)? Maybe a little code and a scenerio would help.
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Location
    LI, NY
    Posts
    4

    Re: [Access] Reading Custom properties

    Hi Rob,

    When I create an app in Access, I manually set two custom properties. In Access 2007 I press the Office button, select Manage, then Database Properties. In the Custom tab I add the two properties that I use for version control (appVesrion and appBuild).

    Depending on the application I may use code to update those properties or I'll do them manually. In either case I use the following function to retrieve the current value of those properties to display them to the user.

    Code:
    Public Function GetCustomProp(strfilename As String, strPropName As String)
        Dim dbs As Database
        Dim cnt As Container
        Dim doc As Document
        Dim strret As String
        
    On Error GoTo GetCustomProp_err
            Set dbs = OpenDatabase(strfilename)
            Set cnt = dbs.Containers("databases")
            Set doc = cnt.Documents("UserDefined")
            strret = doc.Properties(strPropName)
    GetCustomProp_end:
        GetCustomProp = strret
        Exit Function
    GetCustomProp_err:
        If Err = 3270 Then
            strret = "Property Not Found"
        Else
            MsgBox Err & ": " & Err.Description
        End If
        Resume GetCustomProp_end
            dbs.Close
    End Function
    But this code is meant to run within an Access application. What I need is code to get the properties from within a Vb.Net app. I think the key is these 4 lines:
    Set dbs = OpenDatabase(strfilename)
    Set cnt = dbs.Containers("databases")
    Set doc = cnt.Documents("UserDefined")
    strret = doc.Properties(strPropName)

    I guess the 4th line will be OK if I know what the first three should be. Maybe I only need the first one (and the DIM to go with it).

    I will use this function to retrieve the value from both the local file (strfilename) and the master version. If the properties don't match, I will copy the master to the local drive.

    So any suggestions anyone can give me would be appreciated.

    Scott<>
    Microsoft Access MVP 2007
    Author: Microsoft Office Access 2007 VBA
    Last edited by scottgem; Oct 4th, 2009 at 07:32 PM.

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: [Access] Reading Custom properties

    Having only used vb.net at home not really gotten into it I think it is all bassed on classes. So if you can find to get the class of access application you should be able to get the properties off that.

    Wasn't there a search facillity in vb.net that gives you a clue where to look?
    I'd suggest under microsoft...

    or after a quick search on google : try here. Seems to use the oledb wrapper.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Location
    LI, NY
    Posts
    4

    Re: [Access] Reading Custom properties

    I've tried several things, but haven't been able to get anything to work. Would appreciate a stronger nudge.

    Scott<>

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