JP_TechGroup
asked on
Access Title Bar from VBA
I am attempting to update the Application title bar using vba to update the app title based on data in a table. It seems to lag behind and at times be completely wrong. The code is below.
The dlookup function checks a linked table to see if the field value of [isrunning] is true.
If it is, Access should display one title, if it's false another. The function is called whenever a form is opened and from an AUTOEXEC macro at startup.
Note: the startup macro seems to be the only time it even partially works.
The dlookup function checks a linked table to see if the field value of [isrunning] is true.
If it is, Access should display one title, if it's false another. The function is called whenever a form is opened and from an AUTOEXEC macro at startup.
Note: the startup macro seems to be the only time it even partially works.
Public Function update_title_bar()
Dim db As Database, app_title As String
Set db = CurrentDb
If DLookup("isrunning", "tbl_base_status") = True Then
app_title = "Client - Online"
Else
app_title = "Client****OFFLINE****"
End If
db.Properties("AppTitle").Value = app_title
Application.RefreshTitleBar
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the response and you are correct. Unfortunately, this makes no difference.
The update is always "one behind".
By that, I mean that if the look up value changes, you have to close and re-open to see the new title.
This must be some kind of known issue. The code couldn't possibly simpler. A check of my lookup and logic using debug shows that this portion is working correctly.
The update is always "one behind".
By that, I mean that if the look up value changes, you have to close and re-open to see the new title.
This must be some kind of known issue. The code couldn't possibly simpler. A check of my lookup and logic using debug shows that this portion is working correctly.
you can try changing the code.
this worked for me. you will still need to put in the dlookup function but other than that this should work.
Dim aTitle
Dim db As Database
Set db = CurrentDb()
Dim NewTitle As String
NewTitle = nz(Me.Text5,"")
Set aTitle = db.CreateProperty("Apptitl e", dbText, NewTitle)
On Error Resume Next
db.Properties.Append aTitle
db.Properties("AppTitle"). Value = NewTitle
Call Application.RefreshTitleBa r
changeTitle.accdb
this worked for me. you will still need to put in the dlookup function but other than that this should work.
Dim aTitle
Dim db As Database
Set db = CurrentDb()
Dim NewTitle As String
NewTitle = nz(Me.Text5,"")
Set aTitle = db.CreateProperty("Apptitl
On Error Resume Next
db.Properties.Append aTitle
db.Properties("AppTitle").
Call Application.RefreshTitleBa
changeTitle.accdb
ASKER
Still having the same problem. I have to close and re-open the database to get the change to work. This is maddening.
i dont see why. i tried your code and it worked the first time.
i would try compiling your code and trying it again.
i would try compiling your code and trying it again.
ASKER
FOUND IT! Apparently the link to the form icon was changed to a non-existent location. Once I fixed this the title bar updates as it should... weird!
ASKER
and from the on_form_load subs for about 8 forms. These do not work.
I concur, it should!