vba MS 访问属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/698627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MS Access Properties
提问by Curtis Inderwiesche
Where can I find a native list of MS Access properties available through:
我在哪里可以找到可用的 MS Access 属性的本机列表:
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
- AppTitle 可用于访问应用程序的标题
- AppIcon 可用于访问用于应用程序的图标的路径
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.
对于不同的版本,我确定有不同的属性。是否有版本列表?例如,MS Access 2003 具有这些属性...而 MS Access 2007 具有这些属性...等等。
回答by Joel Lucsy
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.
我不相信任何地方都有清单。Tho,Properties 属性是一个集合。您可以遍历它们并获取所有关联的。您必须在您感兴趣的所有 MS Access 版本中执行此操作。进一步说明,几乎所有内部对象,例如表、字段、查询等,都具有属性。字段属性特别有用,因为您可以指定 MS Access 链接和向用户显示字段的方式。
回答by Fionnuala
There is a properties collection:
有一个属性集合:
Sub ListProps()
For i = 0 To CurrentDb.Properties.Count - 1
Debug.Print CurrentDb.Properties(i).Name
Next
End Sub
回答by DJ.
回答by DJ.
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