Link to home
Start Free TrialLog in
Avatar of thandel
thandel

asked on

MS Access How to force icon to refresh

I am using a MS Access 2003 database on a NAS.  Its working fine but sometimes the application icon I specified in the DB startup options doesn't always display.  If I close and reopen the DB it does.

Is there anyway I can force a refresh to read the application icon after the DB is opened? (VBA code on when a form opens for example.)
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Do you mean the little Icon of the application ?
Check the article from MS : https://docs.microsoft.com/en-us/office/vba/api/access.application.appicon
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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thandel
thandel

ASKER

Anders love the simple approach... not sure why but it didn't get the icon to refresh.    John I will test your solution but given Anders didn't work I am a bit suspicious that it might have similar results.
Avatar of thandel

ASKER

Hi Anders your solution had worked... I just had implemented it in the wrong area ... thanks!