Group:  Microsoft Access » microsoft.public.access.adp.sqlserver
Thread: How to get and set Custom Database properties in ADP?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to get and set Custom Database properties in ADP?
"Bill" <A[ at ]B.com> 06.12.2005 19:54:21
Most of my MDB upsized ok but I cannot figure out how to read some custom
database properties that I use.

Example

'read version from Database, Properties, Custom
Set dblocal = CurrentDb()
myDBVersion = GetDatabaseProp(dblocal, "Version")

using:

Function GetDatabaseProp(dbDatabase, strPropertyName As String) As Variant
GetDatabaseProp =
dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
End Function


This is proabably because there is no DAO jet DB any more!

So how do I do I point to the equivalent Custom Properties in the ADP?

Thanks

Bill


Re: How to get and set Custom Database properties in ADP?
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 06.12.2005 20:06:46
For ADP:

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

' Properties are string values.
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:

''''' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
Resume Exit_Sub

End Sub

' GetProperty(): returns TRUE if the property was already known; FALSE
otherwise.
' The value itself is passed by argument.

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
''''' Call LogError(Err.Number, Err.Description, cModuleName &
cProcedureName)
Resume Exit_Function

End Function


--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"Bill" <A[ at ]B.com> wrote in message
news:N%llf.13851$6e.11462[ at ]tornado.tampabay.rr.com...
[Quoted Text]
> Most of my MDB upsized ok but I cannot figure out how to read some custom
> database properties that I use.
>
> Example
>
> 'read version from Database, Properties, Custom
> Set dblocal = CurrentDb()
> myDBVersion = GetDatabaseProp(dblocal, "Version")
>
> using:
>
> Function GetDatabaseProp(dbDatabase, strPropertyName As String) As Variant
> GetDatabaseProp =
> dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
> End Function
>
>
> This is proabably because there is no DAO jet DB any more!
>
> So how do I do I point to the equivalent Custom Properties in the ADP?
>
> Thanks
>
> Bill
>


Re: How to get and set Custom Database properties in ADP?
"Bill" <A[ at ]B.com> 06.12.2005 20:34:36
Thanks,

I looked at this and it still does seem quite right.

Sure this code does add properties that I can then read back with

For Each prop In CurrentProject.Properties
Debug.Print prop.Name
Next prop


But they do not appear in the Custom tab of Database Properties dialog

So where are those Custom Properties?


Thanks

Bill


"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:eEa$YCq%23FHA.3872[ at ]TK2MSFTNGP12.phx.gbl...
[Quoted Text]
> For ADP:
>
> 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
>
> ' Properties are string values.
> 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:
>
> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
> cProcedureName)
> Resume Exit_Sub
>
> End Sub
>
> ' GetProperty(): returns TRUE if the property was already known; FALSE
> otherwise.
> ' The value itself is passed by argument.
>
> 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
> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
> cProcedureName)
> Resume Exit_Function
>
> End Function
>
>
> --
> Sylvain Lafontaine, ing.
> MVP - Technologies Virtual-PC
> E-mail: http://cerbermail.com/?QugbLEWINF
>
>
> "Bill" <A[ at ]B.com> wrote in message
> news:N%llf.13851$6e.11462[ at ]tornado.tampabay.rr.com...
>> Most of my MDB upsized ok but I cannot figure out how to read some custom
>> database properties that I use.
>>
>> Example
>>
>> 'read version from Database, Properties, Custom
>> Set dblocal = CurrentDb()
>> myDBVersion = GetDatabaseProp(dblocal, "Version")
>>
>> using:
>>
>> Function GetDatabaseProp(dbDatabase, strPropertyName As String) As
>> Variant
>> GetDatabaseProp =
>> dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
>> End Function
>>
>>
>> This is proabably because there is no DAO jet DB any more!
>>
>> So how do I do I point to the equivalent Custom Properties in the ADP?
>>
>> Thanks
>>
>> Bill
>>
>
>


Re: How to get and set Custom Database properties in ADP?
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 06.12.2005 23:47:17
Oups, sorry, I misread your question.

I'm sorry but these properties are not available from an Access ADP project.
This is also documented in the Help File: search for "database properties"
and you find the following note: « The Database properties of a Microsoft
Access project (.adp) are not available using Visual Basic. »

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"Bill" <A[ at ]B.com> wrote in message
news:wBmlf.58001$1l6.41135[ at ]tornado.tampabay.rr.com...
[Quoted Text]
> Thanks,
>
> I looked at this and it still does seem quite right.
>
> Sure this code does add properties that I can then read back with
>
> For Each prop In CurrentProject.Properties
> Debug.Print prop.Name
> Next prop
>
>
> But they do not appear in the Custom tab of Database Properties dialog
>
> So where are those Custom Properties?
>
>
> Thanks
>
> Bill
>
>
> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
> wrote in message news:eEa$YCq%23FHA.3872[ at ]TK2MSFTNGP12.phx.gbl...
>> For ADP:
>>
>> 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
>>
>> ' Properties are string values.
>> 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:
>>
>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>> cProcedureName)
>> Resume Exit_Sub
>>
>> End Sub
>>
>> ' GetProperty(): returns TRUE if the property was already known; FALSE
>> otherwise.
>> ' The value itself is passed by argument.
>>
>> 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
>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>> cProcedureName)
>> Resume Exit_Function
>>
>> End Function
>>
>>
>> --
>> Sylvain Lafontaine, ing.
>> MVP - Technologies Virtual-PC
>> E-mail: http://cerbermail.com/?QugbLEWINF
>>
>>
>> "Bill" <A[ at ]B.com> wrote in message
>> news:N%llf.13851$6e.11462[ at ]tornado.tampabay.rr.com...
>>> Most of my MDB upsized ok but I cannot figure out how to read some
>>> custom database properties that I use.
>>>
>>> Example
>>>
>>> 'read version from Database, Properties, Custom
>>> Set dblocal = CurrentDb()
>>> myDBVersion = GetDatabaseProp(dblocal, "Version")
>>>
>>> using:
>>>
>>> Function GetDatabaseProp(dbDatabase, strPropertyName As String) As
>>> Variant
>>> GetDatabaseProp =
>>> dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
>>> End Function
>>>
>>>
>>> This is proabably because there is no DAO jet DB any more!
>>>
>>> So how do I do I point to the equivalent Custom Properties in the ADP?
>>>
>>> Thanks
>>>
>>> Bill
>>>
>>
>>
>
>


Re: How to get and set Custom Database properties in ADP?
"Bill" <A[ at ]B.com> 07.12.2005 13:51:52
Hmmm.
Sounds like a bug to me.

Anyway, the approach you suggested will work, and if I use a form then I
will be able change them without resorting to code.

Thanks

Bill

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:OO2Wn9r%23FHA.2424[ at ]TK2MSFTNGP10.phx.gbl...
[Quoted Text]
> Oups, sorry, I misread your question.
>
> I'm sorry but these properties are not available from an Access ADP
> project. This is also documented in the Help File: search for "database
> properties" and you find the following note: « The Database properties of
> a Microsoft Access project (.adp) are not available using Visual Basic. »
>
> --
> Sylvain Lafontaine, ing.
> MVP - Technologies Virtual-PC
> E-mail: http://cerbermail.com/?QugbLEWINF
>
>
> "Bill" <A[ at ]B.com> wrote in message
> news:wBmlf.58001$1l6.41135[ at ]tornado.tampabay.rr.com...
>> Thanks,
>>
>> I looked at this and it still does seem quite right.
>>
>> Sure this code does add properties that I can then read back with
>>
>> For Each prop In CurrentProject.Properties
>> Debug.Print prop.Name
>> Next prop
>>
>>
>> But they do not appear in the Custom tab of Database Properties dialog
>>
>> So where are those Custom Properties?
>>
>>
>> Thanks
>>
>> Bill
>>
>>
>> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
>> wrote in message news:eEa$YCq%23FHA.3872[ at ]TK2MSFTNGP12.phx.gbl...
>>> For ADP:
>>>
>>> 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
>>>
>>> ' Properties are string values.
>>> 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:
>>>
>>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>>> cProcedureName)
>>> Resume Exit_Sub
>>>
>>> End Sub
>>>
>>> ' GetProperty(): returns TRUE if the property was already known;
>>> FALSE otherwise.
>>> ' The value itself is passed by argument.
>>>
>>> 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
>>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>>> cProcedureName)
>>> Resume Exit_Function
>>>
>>> End Function
>>>
>>>
>>> --
>>> Sylvain Lafontaine, ing.
>>> MVP - Technologies Virtual-PC
>>> E-mail: http://cerbermail.com/?QugbLEWINF
>>>
>>>
>>> "Bill" <A[ at ]B.com> wrote in message
>>> news:N%llf.13851$6e.11462[ at ]tornado.tampabay.rr.com...
>>>> Most of my MDB upsized ok but I cannot figure out how to read some
>>>> custom database properties that I use.
>>>>
>>>> Example
>>>>
>>>> 'read version from Database, Properties, Custom
>>>> Set dblocal = CurrentDb()
>>>> myDBVersion = GetDatabaseProp(dblocal, "Version")
>>>>
>>>> using:
>>>>
>>>> Function GetDatabaseProp(dbDatabase, strPropertyName As String) As
>>>> Variant
>>>> GetDatabaseProp =
>>>> dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
>>>> End Function
>>>>
>>>>
>>>> This is proabably because there is no DAO jet DB any more!
>>>>
>>>> So how do I do I point to the equivalent Custom Properties in the ADP?
>>>>
>>>> Thanks
>>>>
>>>> Bill
>>>>
>>>
>>>
>>
>>
>
>


Re: How to get and set Custom Database properties in ADP?
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 10.12.2005 22:15:16
Maybe http://www.microsoft.com/technet/community/columns/scripts/sg0305.mspx
..

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"Bill" <A[ at ]B.com> wrote in message
news:YNBlf.18326$6e.5305[ at ]tornado.tampabay.rr.com...
[Quoted Text]
> Hmmm.
> Sounds like a bug to me.
>
> Anyway, the approach you suggested will work, and if I use a form then I
> will be able change them without resorting to code.
>
> Thanks
>
> Bill
>
> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
> wrote in message news:OO2Wn9r%23FHA.2424[ at ]TK2MSFTNGP10.phx.gbl...
>> Oups, sorry, I misread your question.
>>
>> I'm sorry but these properties are not available from an Access ADP
>> project. This is also documented in the Help File: search for "database
>> properties" and you find the following note: « The Database properties of
>> a Microsoft Access project (.adp) are not available using Visual Basic. »
>>
>> --
>> Sylvain Lafontaine, ing.
>> MVP - Technologies Virtual-PC
>> E-mail: http://cerbermail.com/?QugbLEWINF
>>
>>
>> "Bill" <A[ at ]B.com> wrote in message
>> news:wBmlf.58001$1l6.41135[ at ]tornado.tampabay.rr.com...
>>> Thanks,
>>>
>>> I looked at this and it still does seem quite right.
>>>
>>> Sure this code does add properties that I can then read back with
>>>
>>> For Each prop In CurrentProject.Properties
>>> Debug.Print prop.Name
>>> Next prop
>>>
>>>
>>> But they do not appear in the Custom tab of Database Properties dialog
>>>
>>> So where are those Custom Properties?
>>>
>>>
>>> Thanks
>>>
>>> Bill
>>>
>>>
>>> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
>>> wrote in message news:eEa$YCq%23FHA.3872[ at ]TK2MSFTNGP12.phx.gbl...
>>>> For ADP:
>>>>
>>>> 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
>>>>
>>>> ' Properties are string values.
>>>> 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:
>>>>
>>>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>>>> cProcedureName)
>>>> Resume Exit_Sub
>>>>
>>>> End Sub
>>>>
>>>> ' GetProperty(): returns TRUE if the property was already known;
>>>> FALSE otherwise.
>>>> ' The value itself is passed by argument.
>>>>
>>>> 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
>>>> ''''' Call LogError(Err.Number, Err.Description, cModuleName &
>>>> cProcedureName)
>>>> Resume Exit_Function
>>>>
>>>> End Function
>>>>
>>>>
>>>> --
>>>> Sylvain Lafontaine, ing.
>>>> MVP - Technologies Virtual-PC
>>>> E-mail: http://cerbermail.com/?QugbLEWINF
>>>>
>>>>
>>>> "Bill" <A[ at ]B.com> wrote in message
>>>> news:N%llf.13851$6e.11462[ at ]tornado.tampabay.rr.com...
>>>>> Most of my MDB upsized ok but I cannot figure out how to read some
>>>>> custom database properties that I use.
>>>>>
>>>>> Example
>>>>>
>>>>> 'read version from Database, Properties, Custom
>>>>> Set dblocal = CurrentDb()
>>>>> myDBVersion = GetDatabaseProp(dblocal, "Version")
>>>>>
>>>>> using:
>>>>>
>>>>> Function GetDatabaseProp(dbDatabase, strPropertyName As String) As
>>>>> Variant
>>>>> GetDatabaseProp =
>>>>> dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value
>>>>> End Function
>>>>>
>>>>>
>>>>> This is proabably because there is no DAO jet DB any more!
>>>>>
>>>>> So how do I do I point to the equivalent Custom Properties in the ADP?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Bill
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net