pseudo calendar in a report help.

  • Thread starter Thread starter Steven Greenberg
  • Start date Start date
S

Steven Greenberg

Greetings,

I am working on altering a report that I use as a signin sheet which
basically has a grid in calendar format. I have lines making up the grid
and used to just write in the given date. I then added a small text box
linked to the calling form which at least determines the first day of
that month and places a "1" in the box. I would like to extend this
feature and have the report open with the full range of dates in their
proper places. So far the way I do the single "1" is I have seven
textboxes on my calling form which via vba I determine which day of the
week the first of the specific month/year falls on. I then blank out the
other six and the first line of the grid on the report just has the
textboxes' control source to be one of the textboxes on the calling
form. works great. I was thinking of just placing a set of 42 boxes on
the form (hidden away) and somehow programming those 42 boxes to layout
the grid. then just do the same with the report, setting the control
source to one of the text boxes. What I would need advice on is how to
populate the 42 boxes on the form once I know the first day. If this was
straight VB, I would use a loop and the control array and it would be a
cinch. but I am having trouble recreating this in Access. Any help or
other suggestions or examples of something like this would be greatly
appreciated. Thanks in advance
Steve Greenberg
 
I'm not real clear what your calendar would look like. You can use the line
method to draw a calendar with code in the On Page event. Copy the following
into the on page event of a report and make sure the width is at least 7
inches.

There are other calendar style reports at
http://www.invisibleinc.com/divFiles.cfm?divDivID=4

Private Sub Report_Page()
Dim lngDayHeight As Long
Dim lngDayWidth As Long
Dim datRptDate As Date
Dim intStartWeek As Integer
Dim lngTopMargin As Long
Dim dat1stMth As Date
Dim datDay As Date
Dim lngTop As Long
Dim lngLeft As Long
datRptDate = Date
dat1stMth = DateSerial(Year(datRptDate), Month(datRptDate), 1)
intStartWeek = DatePart("ww", dat1stMth)
lngDayHeight = 2160 'one & half inch
lngDayWidth = 1440 'one inch
lngTopMargin = 720 'half inch
Me.FontSize = 22
'loop through all days in month
For datDay = dat1stMth To DateAdd("m", 1, dat1stMth) - 1
'find the top and left corner
lngTop = (DatePart("ww", datDay) - intStartWeek) * _
lngDayHeight + lngTopMargin
lngLeft = (Weekday(datDay) - 1) * lngDayWidth
If Weekday(datDay) = 1 Or Weekday(datDay) = 7 Then
Me.DrawWidth = 8
Else
Me.DrawWidth = 1
End If
'draw a rectangle for day
Me.Line (lngLeft, lngTop)-Step _
(lngDayWidth, lngDayHeight), , B
Me.CurrentX = lngLeft + 50
Me.CurrentY = lngTop + 50
Me.Print Day(datDay)
Next
End Sub
 
Back
Top