Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / January 2007

Tip: Looking for answers? Try searching our database.

Accessing custom properties for an adp file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe - 29 Jan 2007 19:21 GMT
I want to be able to define and manipulate custom office properties
for an ADP file from VBA code within the ADP.  Now, I can
interactively right click on the file, choose properties, choose
custom, and create a custom property and value.  The property and
value even persist into the ade file I make from the adp.  So far, so
good.

The problem is I can't come up with any way to set or even read these
custom properties from vba inside the adp file.  I've seen some
examples of doing it with word 2003, but nothing for Access...let
alone Access adp files.  I've got to believe that since I can set and
retreive the data from the UI, there's got to be an api somewhere I
can call...but short of exporting the dll functions from MSAccess.EXE
and trying to guess, I can't seem to find a way.  Anyone?

Alternatively, is there any way to associate metadata with an adp file
that can be read and written from within vba?  The metadata must
persist across executions, not be loaded from an external
source...otherwise i could sneak it into the tag property of a startup
form or something.  Any out of the box ideas welcome...or if there's
something blindingly obvious that I'm missing.
Sylvain Lafontaine - 29 Jan 2007 20:57 GMT
To my knowledge, you can't read/write the custom office properties from VBA
withing an ADP project.  (But you can with a MDB file; see the fourth
message in the thread
http://groups.google.ca/group/microsoft.public.access.tablesdbdesign/browse_frm/
thread/215eb44a0d6846ac/91720a37202fca67#91720a37202fca67
.

This is one of these numerous things that have been left hanging up by MS
for ADP.  However, you can have metadata properties that can be read/write
from VBA within ADP and that will persist from execution to execution:

Private Const cerrPropertyNotFound As Integer = 2455  ' For ADP, not MDB.

Public Sub Debug_DisplayProperties()

   Dim db As CurrentProject
   Set db = Application.CurrentProject

   Dim i
   For i = 0 To db.Properties.Count - 1
       Debug.Print db.Properties(i).name & ": " & db.Properties(i)
   Next

End Sub

Public Sub SetProperty(ByVal strPropName As String, _
   ByVal varPropType_Bidon As Integer, _
   ByVal varPropValue As Variant)

   Const cProcedureName As String = "SetProperty"
   On Error GoTo Err_Handler

   Dim db As CurrentProject
   Set db = Application.CurrentProject

   If (IsNull(varPropValue)) Then varPropValue = ""

   Dim i
   For i = 0 To db.Properties.Count - 1
       If (db.Properties(i).name = strPropName) Then
           db.Properties(strPropName).Value = varPropValue
           GoTo Exit_Sub
       End If
   Next

   db.Properties.Add strPropName, varPropValue

Exit_Sub:
   On Error GoTo 0
   Set db = Nothing
   Exit Sub

Err_Handler:
   ' Err_Handler: utilisée dans l'ancienne version.

   Select Case err
       Case cerrPropertyNotFound
       db.Properties.Add strPropName, varPropValue

       Case Else
           ' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
   End Select

   Resume Exit_Sub

End Sub

   ' GetProperty() : return True if the property exists in the collection.

Public Function GetProperty(ByVal strPropName As String, _
   ByRef strPropValue As Variant) As Boolean

   Const cProcedureName As String = "GetProperty"
   On Error GoTo Err_Handler

   Dim db As CurrentProject
   Set db = Application.CurrentProject

   Dim i
   For i = 0 To db.Properties.Count - 1
       If (db.Properties(i).name = strPropName) Then
           strPropValue = db.Properties(strPropName)
           GetProperty = True
           GoTo Exit_Function
       End If
   Next

   GetProperty = False

Exit_Function:
   On Error GoTo 0
   Set db = Nothing
   Exit Function

Err_Handler:
   GetProperty = False

   Select Case err
   Case cerrPropertyNotFound
   Case Else
        ' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
   End Select

   Resume Exit_Function

End Function

Signature

Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)

>I want to be able to define and manipulate custom office properties
> for an ADP file from VBA code within the ADP.  Now, I can
[quoted text clipped - 17 lines]
> form or something.  Any out of the box ideas welcome...or if there's
> something blindingly obvious that I'm missing.
CyberDwarf - 30 Jan 2007 17:44 GMT
Joe

Create with:-

CurrentProject.Properties.Add "PropertyName", "PropertyValue"

Read with:-

Dim P As AccessObjectProperty
   AccessPropExists = False
   For Each P In CurrentProject.Properties
       If P.name = PropertyName Then
           AccessPropExists = True
       End If
   Next P

HTH

Steve
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.