How can I set the Application Icon with code instead of in the StartUp window? On occasion the database is installed on different(mirrored)drives so I can't use the StartUp window to set the icon?
I found some code that should do the trick but I am getting a Property Not Found error when I run the code. The function is run on the OnClose action of the splashscreen. strDBPath is a variable I set to the location of the backend.
Can anybody see my error? Thanks.
Public Function AssignIcon()
Dim db As Database
Dim strIconPath As String
Set db = CurrentDb
strIconPath = strDBPath & "Icon1.ico"
db.Properties("AppIcon").Value = strIconPath
Application.RefreshTitleBar
Access doesn't expose this property for VBA to use. You'll have to append the property if it's not already available, and you determine if the property's available by trapping for error 3270.
Here's a function I've used in the past:
[tt]Function ChangeProperty(strPropName As String, varPropType As String, varPropValue As Variant) As Integer
PROC_EXIT:
On Error Resume Next
Set prp = Nothing
Set dbs = Nothing
Exit Function
PROC_ERROR:
If Err.Number = 3270 Then
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Resume PROC_EXIT
End If
End Function
[/tt]
To use this function to change the icon, I would have the following in my startup procedure:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.