Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic dates on Report

Status
Not open for further replies.

jgoldfish

Programmer
Sep 29, 2003
1
SG
Hi, I am a new user using MS Access and this website.
I would like to generate a schedule report that display dynamic date columns. For example in the MOnth of April, I will have 30 columns. Each column header display each day in terms of the day of Month(1/2/3/..30) and the day of week (i.e. Mon/Tues/.../Sun). Can someone please kindly share me how I can achieve this? Thank you in advance.
 
Hi

Not sure which bit you do not understand

To Achieve the column headings 1 April thru 30 April

define 30 labels in the Page Header section, name them lblDate1, lblDate2...lblDate30 and put code so in the on open event of the report

Private Sub Report_Open(Cancel As Integer)
Dim datDate As Date
Dim i As Integer
datDate = CDate("01/04/03")
i = 1
Do Until datDate = CDate("30/04/03")
Report.Controls("lblDate" & i).Caption = datDate
datDate = DateAdd("d", 1, datDate)
i = i + 1
Loop
End Sub

Other thing you might find useful

If you going to do 'any' month you need 31 columns, and teh ability to set the visible property of some of them to false, for 'short' months (eg those with less than 31 days)

A function you may find it useful to look up date related functions in help eg Month(), which will return the month as a number 1-12 from a given date.

Hope this helps

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top