tags:

views:

562

answers:

5

Where can I find a native list of MS Access properties available through:

 CurrentDb.Properties("Property_Name_Here")

For example, I know;

  • AppTitle is available to access the title of the application
  • AppIcon is available to access the path of the icon used for the application

For different versions I am sure there are different properties. Are there lists by version? So for example, MS Access 2003 has these properties... while MS Access 2007 has these properties... and so on.

+3  A: 

I don't believe there is a list anywhere. Tho, the Properties property is a collection. You can iterate over them and get all the ones associated. You'd have to do this all the versions of MS Access you're interested in. To further expound, almost all the internal objects, e.g. tables, fields, queries, etc. have properties. The field properties are particularly useful as you can assign how MS Access links and displays the field to the user.

Joel Lucsy
+2  A: 

It's hard to find that kind of info.

I did find a link here for Access-defined DAO properties

DJ
Wow, I could've used that list years ago.
Joel Lucsy
+3  A: 

There is a properties collection:

Sub ListProps()
    For i = 0 To CurrentDb.Properties.Count - 1
        Debug.Print CurrentDb.Properties(i).Name
    Next
End Sub
Remou
Why use a counter instead of a property variable so you can use a FOR/EACH loop, which is less code and involves fewer value lookups?
David-W-Fenton
No good reason at all.
Remou
Yeah, Remou: you didn't *explicitly* declare the Sub as Public and ListProps is too vague a name. You didn't Dim the variable i, so you're just assuming that Option Explicit is omitted, which is just encouraging bad practices. It would be more efficient to use With CurrentDb.Properties...
onedaywhen
...and Debug.Print is a poor substitute for proper logging. You just didn't think this one through, did you...? Yes, my tongue is firmly embedded in cheek :)
onedaywhen
Oaug oug <dies> :)
Remou
A: 

Would this be ok? :)

Option Compare Database
Option Explicit

Private Sub btnShowDbProps_Click()
On Error GoTo Err_btnShowDbProps_Click

  Dim prp As DAO.Property
  Dim dbs As Database
  Dim strProps As String

  Set dbs = CurrentDb

  For Each prp In dbs.Properties
    Dim propval As String
    propval = "<not defined>"

    On Error Resume Next
    propval = CStr(prp.value)

    If propval = vbNullString Then propval = "<empty>"

    strProps = strProps & prp.Name & "=" & propval & " (" & PropertyType(prp.Type) & ")" & vbNewLine
    Debug.Print strProps
  Next

  MsgBox strProps

Exit_btnShowDbProps_Click:
    Exit Sub

Err_btnShowDbProps_Click:
    MsgBox Err.Description
    Resume Exit_btnShowDbProps_Click

End Sub

Function PropertyType(intType As Integer) As String

   Select Case intType
      Case dbBoolean
         PropertyType = "dbBoolean"
      Case dbByte
         PropertyType = "dbByte"
      Case dbInteger
         PropertyType = "dbInteger"
      Case dbLong
         PropertyType = "dbLong"
      Case dbCurrency
         PropertyType = "dbCurrency"
      Case dbSingle
         PropertyType = "dbSingle"
      Case dbDouble
         PropertyType = "dbDouble"
      Case dbDate
         PropertyType = "dbDate"
      Case dbText
         PropertyType = "dbText"
      Case dbLongBinary
         PropertyType = "dbLongBinary"
      Case dbMemo
         PropertyType = "dbMemo"
      Case dbGUID
         PropertyType = "dbGUID"
      Case Else
         PropertyType = "Unknown:" & intType
   End Select

End Function
A: 

Would this be ok? :)

Option Compare Database
Option Explicit

Private Sub btnShowDbProps_Click()
On Error GoTo Err_btnShowDbProps_Click

  Dim prp As DAO.Property
  Dim dbs As Database
  Dim strProps As String

  Set dbs = CurrentDb

  For Each prp In dbs.Properties
    Dim propval As String
    propval = "<not defined>"

    On Error Resume Next
    propval = CStr(prp.value)

    If propval = vbNullString Then propval = "<empty>"

    strProps = strProps & prp.Name & "=" & propval & " (" & PropertyType(prp.Type) & ")" & vbNewLine
    Debug.Print strProps
  Next

  MsgBox strProps

Exit_btnShowDbProps_Click:
    Exit Sub

Err_btnShowDbProps_Click:
    MsgBox Err.Description
    Resume Exit_btnShowDbProps_Click

End Sub


Function PropertyType(intType As Integer) As String

   Select Case intType
      Case dbBoolean
         PropertyType = "dbBoolean"
      Case dbByte
         PropertyType = "dbByte"
      Case dbInteger
         PropertyType = "dbInteger"
      Case dbLong
         PropertyType = "dbLong"
      Case dbCurrency
         PropertyType = "dbCurrency"
      Case dbSingle
         PropertyType = "dbSingle"
      Case dbDouble
         PropertyType = "dbDouble"
      Case dbDate
         PropertyType = "dbDate"
      Case dbText
         PropertyType = "dbText"
      Case dbLongBinary
         PropertyType = "dbLongBinary"
      Case dbMemo
         PropertyType = "dbMemo"
      Case dbGUID
         PropertyType = "dbGUID"
      Case Else
         PropertyType = "Unknown:" & intType
   End Select

End Function