如何以编程方式访问MS Access 2003中的“应用程序图标”路径?
答案 0 :(得分:2)
它是数据库对象的自定义属性(“AppIcon”)。
Set dbs = CurrentDb
sAppIconPath = dbs.Properties("AppIcon")
注意 - 如果属性不存在,您将收到错误。
Access帮助中的此代码显示了如何创建属性:
实施例
以下示例说明如何更改Microsoft Access数据库(.mdb)中的AppIcon和AppTitle属性。如果尚未设置或创建属性,则必须使用CreateProperty方法创建它们并将它们附加到Properties集合。
Sub cmdAddProp_Click()
Dim intX As Integer
Const DB_Text As Long = 10
intX = AddAppProperty("AppTitle", DB_Text, "My Custom Application")
intX = AddAppProperty("AppIcon", DB_Text, "C:\Windows\Cars.bmp")
CurrentDb.Properties("UseAppIconForFrmRpt") = 1
Application.RefreshTitleBar
End Sub
Function AddAppProperty(strName As String, _
varType As Variant, varValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue
AddAppProperty = True
AddProp_Bye:
Exit Function
AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If
End Function