Solved

Access Title Bar from VBA

Posted on 2011-02-24
8
569 Views
Last Modified: 2012-05-11
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.
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

Open in new window

0
Comment
Question by:JP_TechGroup
  • 4
  • 3
8 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 34972093
That should work. Here's an article that shows more detail, but in essence you calling RefreshTitleBar should work:

http://msdn.microsoft.com/en-us/library/dd903046%28v=office.12%29.aspx

Where are you calling this?
0
 

Author Comment

by:JP_TechGroup
ID: 34972198
It runs from an AUTOEXEC macro at program open (which is the only time it works at all)
and from the on_form_load subs for about 8 forms. These do not work.
I concur, it should!
0
 
LVL 10

Assisted Solution

by:conagraman
conagraman earned 250 total points
ID: 34981886
i dont know if this helps but i noticed one thing in your syntax. i dont think you can use dlookup in the way you are trying.
DLookup("isrunning", "tbl_base_status") = True

it wont return a true false statement instead it will return the first record in isrunning from the tbl_base_status. if the field should return the word true then put quotes around the = "true"

0
 

Author Comment

by:JP_TechGroup
ID: 34982384
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.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 10

Expert Comment

by:conagraman
ID: 34982854
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("Apptitle", dbText, NewTitle)
On Error Resume Next
db.Properties.Append aTitle

db.Properties("AppTitle").Value = NewTitle
Call Application.RefreshTitleBar
changeTitle.accdb
0
 

Author Comment

by:JP_TechGroup
ID: 34997741
Still having the same problem. I have to close and re-open the database to get the change to work. This is maddening.
0
 
LVL 10

Expert Comment

by:conagraman
ID: 34997876
i dont see why. i tried your code and it worked the first time.
i would try compiling your code and trying it again.
0
 

Author Closing Comment

by:JP_TechGroup
ID: 34997911
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!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now