Display Date on the Toolbar?

  • Thread starter Thread starter Diarmuid
  • Start date Start date
D

Diarmuid

Hi
My client does all their work on a weekly basis. So it would be very
useful if the current week ending date could displayed all the time. How
would I display this date on the toolbar?
Thanks
Diarmuid
 
Hi,

I'll need the answers to these questions before giving the solution:

1. Do you already have a toolbar created?

2. If yes, what is the name of the toolbar you have created?

3. If you have your own toolbar, how many items are on this toolbar?

4. Is "the end of the week" for you whatever is the Friday's date or some other day?

Jeff Conrad
Access Junkie
Bend, Oregon
 
Hi,

In case you come back, here's a solution that works in
Access 97 tests. Haven't tested on later versions.

1. Create a new standard module and copy/paste this code:

Function EndOfWeek(D As Variant, Optional _
FirstWeekday As Integer) As Variant
'
' Returns the date representing the
' last day of the current week.
'
' Arguments:
' D = Date
' FirstWeekday = (Optional argument)
' Integer that represents the first
' day of the week (e.g., 1=Sun..7=Sat).
'
If IsMissing(FirstWeekday) Then
'Sunday is the assumed first day of week.
EndOfWeek = D - WeekDay(D) + 7
Else
EndOfWeek = D - WeekDay(D, FirstWeekday) + 6
End If
End Function


Compile, save the module, and name it modEndOfWeek

2. I have a toolbar called MyToolbar.

3. I have only one item on this toolbar initially called
DisplayDate, but that changes when the code is run. So I
use the Index value in the code.

4. This code assumes Friday is the end date you want to
show on the toolbar button.

5. In the Form's Open event put this code in:

Private Sub Form_Open(Cancel As Integer)
CommandBars("MyToolBar").Controls(1).Caption _
= EndOfWeek(Date)
End Sub

6. Assign this toolbar to the form on the Form's
Properties list. Position the toolbar in the upper left
corner (or wherever else you would like).

7. Compile the code and save the form. When you open the
form the toolbar will display the current week's Friday
date.

Hope that helps,
Jeff Conrad
Access Junkie
Bend, Oregon
-----Original Message-----
Hi,

I'll need the answers to these questions before giving the solution:

1. Do you already have a toolbar created?

2. If yes, what is the name of the toolbar you have created?

3. If you have your own toolbar, how many items are on this toolbar?

4. Is "the end of the week" for you whatever is the
Friday's date or some other day?
 
Private Sub Form_Open(Cancel As Integer)
CommandBars("MyToolBar").Controls(1).Caption = EndOfWeek(Date)
End Sub

is what I was lookin for.Thanks!
Diarmuid
 
Back
Top