Application Icon path in MS Access

雨燕双飞 提交于 2019-12-12 21:22:26

问题


How do you access the Application Icon path in MS Access 2003 programmatically?


回答1:


It's a custom property ("AppIcon") of the database object.

Set dbs = CurrentDb
sAppIconPath = dbs.Properties("AppIcon")

Note - you will get an error if the property doesn;t exist.

This code from the Access Help shows how to create the property:

Example

The following example shows how to change the AppIcon and AppTitle properties in a Microsoft Access database (.mdb). If the properties haven't already been set or created, you must create them and append them to the Properties collection by using the CreateProperty method.

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


来源:https://stackoverflow.com/questions/698418/application-icon-path-in-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!