Solved Refresh app title and favicon (1 Viewer)

zelarra821

Registered User.
Local time
Today, 07:33
Joined
Jan 14, 2019
Messages
813
Hello. I have a Settings form where the user can change the app title and favicon. However, for it to take effect you have to restart the database, and it's a pain. I want to know if it is possible to refresh the title from within the database itself, without having to go back and forth. Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:33
Joined
Oct 29, 2018
Messages
21,537
The app title yes, I don't know about the fav icon. Check out the RunCommand method or the Application object. I think there is a RefreshTitle something in there.

Sent from phone...
 

zelarra821

Registered User.
Local time
Today, 07:33
Joined
Jan 14, 2019
Messages
813
I have this code in the AfterUpdate event:

Code:
    Dim dbs As Object
    Set dbs = CurrentDb
    dbs.Properties!AppTitle = Me.TituloAplicacion
    Application.RefreshTitleBar

but it doesn't work
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:33
Joined
Sep 12, 2006
Messages
15,709
Just advise users it will take effect next time. That's what many MS Access system settings do.
If you are doing it as the developer, you might need to restart a few times, but it's a once-only process, isn't it?
 

Josef P.

Well-known member
Local time
Today, 07:33
Joined
Feb 2, 2023
Messages
846
but it doesn't work
Does an error message appear because the property does not (yet) exist?

Note: Application.RefreshTitleBar would show the new text immediately.
 

bastanu

AWF VIP
Local time
Yesterday, 22:33
Joined
Apr 13, 2010
Messages
1,402
This is how I do it and it works immediately:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If MsgBox("Do you want to change the version number?" & Chr(13) & _
              "This should only be done by the Developer or the Super User...", vbCritical + vbYesNo, "Confirm version change!") = vbNo Then
          Me.Undo
    End If
    'update the startup
    
    SetApplicationTitle ("YourDatabaseName Version " & Me.CurrentVersion & " Revised " & Format(Nz(Me.ChangeDate, Date), "dd-mmm-yyyy"))
End Sub
Function SetApplicationTitle(ByVal MyTitle As String)
   If SetStartupProperty("AppTitle", dbText, MyTitle) Then
      Application.RefreshTitleBar
   Else
      MsgBox "ERROR: Could not set Application Title"
   End If
End Function

Function SetStartupProperty(prpName As String, _
      prpType As Variant, prpValue As Variant) As Integer
   Dim db As DAO.Database, PRP As DAO.Property, WS As Workspace
   Const ERROR_PROPNOTFOUND = 3270

   Set db = CurrentDb()

   ' Set the startup property value.
   On Error GoTo Err_SetStartupProperty
   db.Properties(prpName) = prpValue
   SetStartupProperty = True

Bye_SetStartupProperty:
   Exit Function

Err_SetStartupProperty:
   Select Case Err
   ' If the property does not exist, create it and try again.
   Case ERROR_PROPNOTFOUND
      Set PRP = db.CreateProperty(prpName, prpType, prpValue)
      db.Properties.Append PRP
      Resume
   Case Else
      SetStartupProperty = False
      Resume Bye_SetStartupProperty
   End Select
End Function

Cheers,
 

zelarra821

Registered User.
Local time
Today, 07:33
Joined
Jan 14, 2019
Messages
813
I got it, and with Favicon too. The problem was that I was using another code for the same function. Only a question. How do I delete favicon from options? When I delete the icon, it remains in the options and then it don't change the title inmediately.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:33
Joined
Feb 19, 2002
Messages
43,478
Keep in mind that when you allow the user to make changes like this, they will be LOST when you distribute a new copy of the FE. This is not useful functionality. It is "cute". Don't waste your time or your employer's money.
 

zelarra821

Registered User.
Local time
Today, 07:33
Joined
Jan 14, 2019
Messages
813
I do this for myself, because I like it, and I want to learn. It does not depend on anyone who can cost money.

What I have gotten so far is the following:

Code:
     SetApplicationTitle DLookup("ApplicationTitle", "T00Configuration")
     If Not IsNull(DLookup("Favicon", "T00Settings")) Then SetApplicationFavicon DLookup("Favicon", "T00Settings")

The problem comes when the Favicon is null, which is saved where I show in the image attached.

And I don't know how I can remove it so that everything continues to work as such.
 

Attachments

  • ScreenShot001.jpg
    ScreenShot001.jpg
    344 KB · Views: 39

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:33
Joined
May 7, 2009
Messages
19,246
to Remove the Icon/Title, you need to Remove the Property.
you can change the function to Accept "Null" as Property Value.
then modify the function to check if Null is passed and Delete the property:
Code:
Function SetStartupProperty(prpName As String, _
      prpType As Variant, prpValue As Variant) As Integer
   Dim db As DAO.Database, PRP As DAO.Property, WS As Workspace
   Const ERROR_PROPNOTFOUND = 3270

   Set db = CurrentDb()

   ' Set the startup property value.
   On Error GoTo Err_SetStartupProperty
  
   If IsNull(prpValue) Then
       'arnelgp
       'delete if the Value is Null
       db.Properties.Delete prpName
   Else
       db.Properties(prpName) = prpValue
   End If
  
   SetStartupProperty = True

Bye_SetStartupProperty:
   Exit Function

Err_SetStartupProperty:
   Select Case Err
   ' If the property does not exist, create it and try again.
   Case ERROR_PROPNOTFOUND
      Set PRP = db.CreateProperty(prpName, prpType, prpValue)
      db.Properties.Append PRP
      Resume
   Case Else
      SetStartupProperty = False
      Resume Bye_SetStartupProperty
   End Select
End Function


To remove, the AppIcon:

SetStartupProperty "AppIcon",DB_TEXT, Null
 

Users who are viewing this thread

Top Bottom