RefreshTitleBar problems

F

Fred Boer

Hello (again!):

Has anyone experienced a problem with RefreshTitleBar not actually
refreshing the title bar? I'm using it, and it seems that it doesn't
actually work - but the new title bar name *does* show up if the .mdb is
closed and reopened, and if I do a break point, it appears that the value of
the title bar has been set properly by my code... The process involves 3
forms: one form which allows user to change title bar and app icon, the back
end .mdb, and another form which I want to pull these values from the back
end tables, but which doesn't allow the user to make changes.

Here's the code: (Please forgive my inclusion of all the code, but I think
it might be necessary/helpful to see it in context,)

Private Sub Form_Open(Cancel As Integer)

Const conPropNotFoundError = 3270

Dim db As DAO.Database

On Error GoTo ErrorHandler


'Load various values for labels and system settings...

Me.lblDate.Caption = Format(Date, "Long Date")


If Len(DLookup("VersionNumber", "tblSettings") & "") = 0 Then
Me.lblVersion.Caption = "Version " & 2
Else
Me.lblVersion.Caption = "Version " & DLookup("VersionNumber",
"tblSettings")
End If

If Len(DLookup("Copyright", "tblSettings") & "") = 0 Then
Me.lblFBLSD.Caption = "Copyright " & Format(Date, "yyyy") & " " & "
Fred Boer Library Systems © "
Else
Me.lblFBLSD.Caption = "Copyright " & Format(Date, "yyyy") & " " &
DLookup("Copyright", "tblSettings") & "©"
End If

If Not IsNull(DLookup("PathToSplashScreenPicture", "tblSettings")) Then
If Dir(DLookup("PathToSplashScreenPicture", "tblSettings")) = ""
Then
MsgBox "The custom image, which should be displayed now, cannot
be found." & vbCrLf & "Please provide a valid path to an image of your
choice." & vbCrLf & "On the main menu, use ""Tools>System Settings"" to
specify an image of your choice.", vbOKOnly + vbInformation,
Nz(DLookup("AppTitle", "tblSettings"), "My Library")
Me.lblPleaseSelectPicture.Visible = True
Me.boxDefault.Visible = True
Me.imgSplashScreen.Visible = False
Else
Me.imgSplashScreen.Picture =
DLookup("PathToSplashScreenPicture", "tblSettings")
Me.imgSplashScreen.Visible = True
Me.lblPleaseSelectPicture.Visible = False
Me.boxDefault.Visible = False
End If
Else
Me.lblPleaseSelectPicture.Visible = True
Me.boxDefault.Visible = True
Me.imgSplashScreen.Visible = False
End If

DoCmd.Maximize

Set db = CurrentDb()

'Change application icon

db.Properties!AppIcon = Nz(DLookup("PathToAppIcon", "tblSettings"), "A")
CurrentDb.Properties("UseAppIconForFrmRpt") = 1
Application.RefreshTitleBar

'Change title bar.

db.Properties!AppTitle = Nz(DLookup("AppTitle", "tblSettings"), "My
Library")
Application.RefreshTitleBar


'If there is no custom application title or custom application icon, the
code to set these items will cause
'Access to generate an error. The error handling code for this error
will create and append the properties
'to the database. It will try to set the title and icon to the values
given
'in the settings table. If that value is blank, then default values will
be used.
'Access ignores invalid application icon settings and uses the default
Access icon.

db.Close
Set db = Nothing


ExitPoint:
Exit Sub

ErrorHandler:


Select Case Err.Number

Case conPropNotFoundError

'Trap and fix missing application title or icon error...

Dim intX As Integer
Const DB_Text As Long = 10
intX = AddAppProperty("AppTitle", DB_Text, Nz(DLookup("AppTitle",
"tblSettings"), "My Library"))
Application.RefreshTitleBar
intX = AddAppProperty("AppIcon", DB_Text,
Nz(DLookup("PathToAppIcon", "tblSettings"), "A"))
CurrentDb.Properties("UseAppIconForFrmRpt") = 1
Application.RefreshTitleBar

Case 3024
Call fRefreshLinks

Case 3044
Call fRefreshLinks

Case 2220
'Ignore the error about missing image files,since we deal with
that above
Resume Next

Case Else
fncErrorMessage Err.Number, Err.Description

End Select
Resume ExitPoint

End Sub
 
F

Fred Boer

Note: the problem occurs only if the user form does *not* have the appicon
and apptitle properties - i.e. the code to create and append the copies has
to run. In this situation, the main application shows the new icon, but the
icon is not shown on form titlebars until the .mdb is closed and
re-opened...

Hope that is understandable?!

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top