|
-
Oct 4th, 2009, 07:52 AM
#1
Thread Starter
New Member
[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<>
-
Oct 4th, 2009, 01:39 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 4th, 2009, 07:27 PM
#3
Thread Starter
New Member
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.
-
Oct 5th, 2009, 02:06 AM
#4
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.
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...
-
Oct 6th, 2009, 08:08 AM
#5
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|