MS Access How to force icon to refresh

thandel
thandel used Ask the Experts™
on
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.)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
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

Presumably at the time of opening the access database the icon cannot be found. You could try to add this:
Application.RefreshTitleBar

Open in new window

But the question then becomes at which point to have that code? You could try to add it in the first form you open, and see if it makes any difference.

Author

Commented:
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.

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial