printing dates on a timesheet

G

Guest

We are attempting to integrate our company's timesheets into Access 2002,
where we have a worker table with the names, emp numbers etc. The goal is to
be able to click a button, and the timesheets will print out with the name,
id number, department, pay period dates already on the timesheet, where the
worker would then just have to fill in the number of hours worked each day.
The timesheet requires that a "payroll begin date" and "payroll end date" be
printed on the timesheet, and below that is a row of boxes in which the
individual dates for each day of that period are entered.
We took the timesheet and scanned it into the report as the background, then
overlayed text boxes to print the name, id number, department, etc, using the
worker table as the record source for each of these fields.
We used the text box for the payroll begin and end dates, too, so that it
prompts the user to enter the beginning and ending dates of the pay period.
Is there anyway we can use an expression to get the individual dates to
print in the date boxes below, starting with the payroll begin date, and
ending with the payroll end date?
 
D

Duane Hookom

If a payroll period always contains the same number of dates then you
shouldn't need the end date. Assuming you have two text boxes on your report
txtBeginDate and txtEndDate, you can use the following code to draw the date
boxes and add the date. This code would go in the On Print event of the
detail section. There are some values such as intHeight and intTop that you
might need to change.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim intTop As Integer
Dim intWidth As Integer
Dim intNumDates As Integer
Dim intDateWidth As Integer
Dim intHeight As Integer
Dim intDay As Integer
intWidth = Me.Width
intHeight = 720 '.5 inches
intTop = 1440 '1 inch down in the detail section
intNumDates = DateDiff("d", _
Me.txtBeginDate, Me.txtEndDate) + 1
If intNumDates > 0 Then
intDateWidth = intWidth / intNumDates
End If
Me.FontSize = 12
Me.FontBold = True
For intDay = 0 To intNumDates
Me.Line (intDay * intDateWidth, intTop)- _
Step(intDateWidth, intHeight), , B
Me.CurrentX = intDay * intDateWidth + 20
Me.CurrentY = intTop + 100
Me.Print DateAdd("D", intDay, Me.txtBeginDate)
Next
End Sub
 
G

Guest

I'll show this to the guy who's been doing most of the work. Our paydays are
bi-monthly (15th and 30th or the last working day nearest those dates, so we
have 13, 14, 15 or 16 days in a pay period depanding on which month/pay
period it is it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top