Custom icon for access toolbar

scopes456

Registered User.
Local time
, 23:33
Joined
Feb 13, 2013
Messages
89
A nice feature in access you can put your own icon.that works great when your database is local and you can link your icon file ( example c://photos/custom.ico) But what it you want your database to be use in a different location. Is there a way to store the icon within the database so anywhere you open it there is always your custom icon
 
I normally put the app icon in the folder with the back end. My code that runs to relink the tables also reattaches the icon.

You could store the icon in the database as a BLOB. You will still have to extract it from the database an place it in a folder before it can be used.

I actually do this with DLLs , fonts, icons etc. It does require VBA code to load and extract the data.

Example code for setting the icon:

I place the following functions in a code module since I use it to set other application properties
Code:
Function ChangeProperty(strPropName As String, varPropType As String, varPropValue As Variant) As Integer
    
    Dim dbs As DAO.Database
    Dim prp As DAO.Property
   
    Set dbs = CurrentDb
    On Error GoTo PROC_ERROR
    
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

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

To use this function to set/change the icon that is in the same folder as the front end or non-split database try the following at startup:

Code:
ChangeProperty "AppIcon", dbText, Access.CurrentProject.Path & "MyIcon.ico"

Application.RefreshTitleBar

This may also be helpful:

https://msdn.microsoft.com/en-us/library/office/ff197957.aspx
 
Last edited:

Users who are viewing this thread

Back
Top Bottom