Display Date in TitleBar

S

Sreedhar

Hi everybody,

How can I display date and time (or whatever I want to show the user
prominently as a constant reference) in the Application TitleBar through VBA ?

Any help is highly appreciated.
 
M

Marshall Barton

Sreedhar said:
How can I display date and time (or whatever I want to show the user
prominently as a constant reference) in the Application TitleBar through VBA ?


Here's a procedure that I use:

Sub SetAppIcon()
Dim prp As Property

On Error Resume Next

With DBEngine(0)(0).Containers!Databases.Documents!MSysDb
.Properties("AppIcon") = "C:MyIcon.ICO"
If Error.number = 3270 Then
Set prp = .CreateProperty("AppIcon", dbText, _
"C:MyIcon.ICO.ICO")
.Properties.Append prp
Set prp = Nothing
End If

.Properties("AppTitle") = "Test App Title"
If Error.number = 3270 Then
Set prp = .CreateProperty("AppTitle", dbText, _
"Test App Title")
.Properties.Append prp
Set prp = Nothing
End If
RefreshTitleBar
End With

End Sub
 
S

Sreedhar

Hi Marsh,

Thank you for the code. I've slightly changed it and tested. The sub is
running fine but without any results. Any ideas what can be wrong ? I'm using
Access 2003, Windows Xp, if that helps. Here is what I did to your code.
Pardon me if I did something horrible :)

Sub SetAppIcon()
Dim prp As Property

On Error Resume Next

With DBEngine(0)(0).Containers!Databases.Documents!msysdb
.Properties("AppIcon") = "D:CIS.ICO"
If Error.Number = 3270 Then
Set prp = .CreateProperty("AppIcon", dbText, "D:CIS.ICO")
.Properties.Append prp
Set prp = Nothing
End If

.Properties("AppTitle") = "Test App Title" & vbTab & vbTab & _
Format(Date, "mmmm dd, yyyy")
If Error.Number = 3270 Then
Set prp = .CreateProperty("AppTitle", dbText, "Test App Title" & _
vbTab & vbTab & Format(Date, "mmmm dd, yyyy"))
.Properties.Append prp
Set prp = Nothing
End If
RefreshTitleBar
End With

End Sub
 
S

Sreedhar

Hi Marsh,

I've further slightly modified your code and it works great.
Here if what I further did to your code :)

Sub SetAppIcon()
Dim prp As DAO.Property

On Error Resume Next

With DBEngine(0)(0).Containers!Databases.Documents!msysdb
.Properties("AppIcon") = "D:\CIS.ICO"
If Error.Number = 3270 Then
Set prp = .CreateProperty("AppIcon", dbText, "D:\CIS.ICO")
.Properties.Append prp
Set prp = Nothing
End If

.Properties("AppTitle") = "Test App Title" & Space(65) & Format(Date,
"mmmm dd, yyyy")
If Error.Number = 3270 Then
Set prp = .CreateProperty("AppTitle", dbText, "Test App Title" &
space(65) & _
Format(Date, "mmmm dd, yyyy"))
.Properties.Append prp
Set prp = Nothing
End If
RefreshTitleBar
End With

End Sub
 
S

Sreedhar

Hi Marsh,

Thank you for the help. I got it working it now.

BTW, can you please tell me what's the max length possible for an AppTitle ?
 
M

Marshall Barton

Sreedhar said:
Hi Marsh,

Thank you for the help. I got it working it now.

BTW, can you please tell me what's the max length possible for an AppTitle ?


Gald you got things sorted now.

I have no idea how long the AppTitle property can be, but I
would guess at either 256 or 64K bytes. OTOH, who cares
since the only part you can see is the width of the window
less the control, min, max and close buttons.
 
S

Sreedhar

Hi Marsh,

Marshall Barton said:
I have no idea how long the AppTitle property can be, but I
would guess at either 256 or 64K bytes. OTOH, who cares
since the only part you can see is the width of the window
less the control, min, max and close buttons.

I think, the entire width of the TitleBar is not available for the AppTitle.
Only 99 characters are visible, though the property is acepting a string
longer than that. Access Help Files are also silent on this. Anyway, thank
you very much for the help offered.
 
M

Marshall Barton

Sreedhar said:
Hi Marsh,



I think, the entire width of the TitleBar is not available for the AppTitle.
Only 99 characters are visible, though the property is acepting a string
longer than that. Access Help Files are also silent on this. Anyway, thank
you very much for the help offered.


99? That seems like an odd number, but it's a Windows thing
so who knows why they chose it.
 
Top