RefreshTitleBar not working

Bodders
NewLounger
Posts: 5
Joined: 10 Feb 2010, 16:13

RefreshTitleBar not working

Post by Bodders »

Good to virtually meet up with you all again.

Here's an Access issue (bug ?) that I cannot seem to resolve. I have this code which is run by an autoexec macro :

Set dbs = CurrentDb
strTitle = dbs.Containers("Databases").Documents("UserDefined").Properties("ApplicationName")
strTitle = strTitle & " " & dbs.Containers("Databases").Documents("UserDefined").Properties("VersionNumber")
On Error Resume Next
dbs.Properties("Apptitle") = strTitle
If Err.Number = 3270 Then
Set prp = dbs.CreateProperty("AppTitle", "Text", strTitle)
dbs.Properties.Refresh
End If
Application.RefreshTitleBar

However, it does not change the title bar at all - and I do not know why.

Any thoughts ?

Bodders

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RefreshTitleBar not working

Post by HansV »

Welcome to Eileen's Lounge!

Which version of Access are you using, and which database format? I tried your code in Access 2007, and after adding custom properties ApplicationName and VersionNumber, it worked flawlessly. (The database is in a trusted location, so macros run without prompting)
Best wishes,
Hans

Bodders
NewLounger
Posts: 5
Joined: 10 Feb 2010, 16:13

Re: RefreshTitleBar not working

Post by Bodders »

Access 2003 SP3

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RefreshTitleBar not working

Post by HansV »

I'll try it in Access 2003 tomorrow.
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RefreshTitleBar not working

Post by HansV »

I have tested your code in Access 2003, and it works OK there too. I have attached a sample database (Access 2000 format, zipped). If I open it, select File | Database Properties..., activate the Custom tab, change the values of ApplicationName and VersionNumber, then run the AutoExec macro or close and reopen the database, the caption of the Access application window is updated correctly. What happens if you try that?
Database1.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

Bodders
NewLounger
Posts: 5
Joined: 10 Feb 2010, 16:13

Re: RefreshTitleBar not working

Post by Bodders »

Hans

Thanks for your help, but it does not work on my PC. Having trawled through some old code, I found an API call which does work :

Public Declare Function SetWindowText Lib "user32" _
Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long

Call SetWindowText(Application.hWndAccessApp, strTitle)

No idea why this does work & VBA version does not.

Bodders

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RefreshTitleBar not working

Post by HansV »

Does the macro work if you run it manually, from the database window?
Best wishes,
Hans

Bodders
NewLounger
Posts: 5
Joined: 10 Feb 2010, 16:13

Re: RefreshTitleBar not working

Post by Bodders »

Hans - no it does not. The only thing I can suggest is that we cannot make registry changes on our work PC's - would that have an impact ?

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RefreshTitleBar not working

Post by HansV »

I don't think so - the code does not write to the registry.
I'm afraid I don't knoiw why it doesn't work, but fortunately you have found a workaround.
Best wishes,
Hans

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: RefreshTitleBar not working

Post by Wendell »

Bodders wrote:Hans - no it does not. The only thing I can suggest is that we cannot make registry changes on our work PC's - would that have an impact ?
Have you tried setting the Title Bar using the Start-Up parameters - unless we change the title dynamically while the application is in use, we use that approach.
Wendell
You can't see the view if you don't climb the mountain!

Bodders
NewLounger
Posts: 5
Joined: 10 Feb 2010, 16:13

Re: RefreshTitleBar not working

Post by Bodders »

Wendell

That does work, but I wanted to do the whole thing programmatically if I could. The API call sorts it out anyway.