[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<>
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.
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
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.
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<>