Custom Database Properties

  • Thread starter Thread starter Ronald Dodge
  • Start date Start date
R

Ronald Dodge

How do you reach the Customer Database Properties in VBA?

Manually, you can goto File>Database Properties...

Click on the Custom tab

Scroll down to the property you want and look up the value.

I want to be able to do this from VBA.
 
Ronald said:
How do you reach the Customer Database Properties in VBA?

Manually, you can goto File>Database Properties...

Click on the Custom tab

Scroll down to the property you want and look up the value.

I want to be able to do this from VBA.


CurrentDb.Containers("Databases").Documents("UserDefined").Properties("Publisher")
 
Is there any way to create a new custom property, or even write to an existing one
MS Knowledge Base articles 178745 and 170549 contain code for Access 97 that doesn't seem to work in 2000.
 
I found the answer at

http://www.microsoft.com/office/com...sign&mid=2766c6b5-5603-40fe-9dda-396fbd33ffc3

Access 2000 (or DAO) seems to require different parameters. I modified the above URL's code with the previously mentioned knowledge base code to get the following (which works as long as you already have the custom property created in the file/databaseproperties/custom tab:

Function ChangeProperty(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangeProperty_Err

Dim db As DAO.Database
Dim prp As DAO.Property
Dim doc As DAO.Document 'my addition

Const conPropNotFoundError = 3270

Set db = CurrentDb
Set doc = db.Containers!Databases.Documents!UserDefined
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
doc.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True) 'doc.createproperty doesn't work
doc.Properties.Append prp 'but now the append does!

' If we made it this far, it worked!
ChangeProperty = True

ChangeProperty_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function

ChangeProperty_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangeProperty_Exit
End Function
 
Alan said:
Is there any way to create a new custom property, or even write to an existing one?
MS Knowledge Base articles 178745 and 170549 contain code for Access 97 that doesn't seem to work in 2000.
 
Back
Top