Auto-Populate Timesheet

Serious Sam

New Member
Joined
Jan 19, 2005
Messages
30
Hello,
I am creating a Timesheet Database and am trying to automatically populate the data entry form with 'Normal' hours.

The set-up of the data entry form is:

Main form - frmTimeCard - has two fields.
Employee Name
WeekEndingDate

Sub Form - frmTimeCardHours - is a datasheet form with the fields:
Date
PayType (Ordinary hours, O'time, Annual Leave etc)
StartTime
EndTime
Break
Hours (= EndTime - StartTime - Break)

After the user has enter the Name and WeekEndingDate on the main form,
I would like a button on the main form that will populate the first five lines on the datasheet subform with normal hours.
(eg PayType= OrdinaryHrs, Start = 9:00, End = 17:00)
The dates on these five lines would be the five weekdays leading up to and including the WeekEndingDate.

So what I'm searching for is some hints and/or code to populate fields on a datasheet subform.

Any help much appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Me.frmTimeCardHours.Form.StartTime = #0900#
Me.frmTimeCardHours.Form.EndTime = #1700#

Of course this would be inside the loop.
Code:
For x = 4 to 0 step -1
  Me.frmTimeCardHours.Form.[Date]= DateAdd("d", -x, WeekEndingDate)
  ...
  ...
Next x

Ops, that will not do it. You will need to write the data to the table the subform is using as it's source, then requery the subform. The above code has the right idea in it, you just need to write the the table rather than write to the subform.

There is a way to move between subform records within code, but unless you REALLY need to do it, it is much easier to write to the table, then requery.
 
Upvote 0

Forum statistics

Threads
1,224,271
Messages
6,177,611
Members
452,785
Latest member
3110vba

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top