代码之家  ›  专栏  ›  技术社区  ›  Curtis Inderwiesche

MS访问属性

  •  7
  • Curtis Inderwiesche  · 技术社区  · 17 年前

     CurrentDb.Properties("Property_Name_Here")
    

    4 回复  |  直到 17 年前
        1
  •  10
  •   Joel Lucsy    17 年前

        2
  •  7
  •   Fionnuala    17 年前

    Sub ListProps()
        For i = 0 To CurrentDb.Properties.Count - 1
            Debug.Print CurrentDb.Properties(i).Name
        Next
    End Sub
    
        3
  •  3
  •   DJ.    17 年前

    here 对于Access定义的DAO属性

        4
  •  1
  •   Ballamber Ballamber    17 年前

    这样可以吗? :)

    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
    
    推荐文章