After date entered, populate additional dates in other fields

J

J T

Thanks for helping.
Using Access 2003
Client enters date range, in Wk1Date example 3/15/09 and in Wk2Date example
3/28/09.
After the date entrys I want to populate the date in fields Wk1Date1 through
Wk1Date7 and in Wk2Date1 through Wk2Date7.
Wk1Date 1 in my example would be 3/15/09 etc. through 3/21/09 and Wk2Date1
in my example would be 3/22/09 etc. through 3/28/09.
This is for a 2 week payroll program where the first date entered, 3/15/09
will populate the first 7 days and when Wk2Date is entered the next 7 days
will populate additional fields.
Hope this isn't too confusing.
Any help appreciated!
Thanks,
JT
 
M

Mike Painter

J said:
Thanks for helping.
Using Access 2003
Client enters date range, in Wk1Date example 3/15/09 and in Wk2Date
example 3/28/09.
After the date entrys I want to populate the date in fields Wk1Date1
through Wk1Date7 and in Wk2Date1 through Wk2Date7.
Wk1Date 1 in my example would be 3/15/09 etc. through 3/21/09 and
Wk2Date1 in my example would be 3/22/09 etc. through 3/28/09.
This is for a 2 week payroll program where the first date entered,
3/15/09 will populate the first 7 days and when Wk2Date is entered
the next 7 days will populate additional fields.
Hope this isn't too confusing.
Any help appreciated!
Thanks,
JT

Having fields with the same function in a relational database usually leads
to problems that require a lot of coding at some point.
I'm guessing you have fields associated with work hours also.
You will have to code to add them all up and take into account holidays,
week ends and sick days.
Finding out if Fred worked on 3/25/09 (he was out fishing) will be a
problem.
There should be a separate record for each work day.

Having written a payroll program or two I'd rather do one for inventory of
agricultural products where things can come in as a weight and go out as a
size...
 
J

J T

I used Wk2Date to let me know the difference between Week 1 and Week 2.
Currently we are using an Excell speadsheet and that is the way it is setup.
In Excell it is easy to have the worker enter a date in one cell and then
the dates are automatically populated for both weeks. I guess I am just
trying to emulate the spreadsheet, keeping it simple as possible. At the
moment that is all I am looking for. Thanks for the response and I hope that
I answered your questions.
James
 
J

John W. Vinson

I used Wk2Date to let me know the difference between Week 1 and Week 2.
Currently we are using an Excell speadsheet and that is the way it is setup.
In Excell it is easy to have the worker enter a date in one cell and then
the dates are automatically populated for both weeks. I guess I am just
trying to emulate the spreadsheet, keeping it simple as possible. At the
moment that is all I am looking for. Thanks for the response and I hope that
I answered your questions.

You're trying to keep it "as simple as possible" by emulating Excel... but
that will in fact make it MUCH MORE COMPLEX.

Excel is a spreadsheet. Access is a relational database environment. *They are
very different*.

Good design for a spreadsheet is almost by definition inappropriate design for
a relational database! In particular, having a different table field for each
day is *simply wrong*, and will make your database much harder to implement
and use.

Stop, step back, and work *with* Access as it was designed (a relational
database using tall-thin normalized tables) rather than forcing it into a
Procrustean bed emulating a spreadsheet.
 
J

J T

WOW!!
My head is hanging in defeat :-(
Thanks, you both are 100% right. I was just looking for Date +1 and in turn
received a wealth of information.

Thanks guys! I appreciate all of the input.

James

DStegon via AccessMonster.com said:
John said:
You're trying to keep it "as simple as possible" by emulating Excel... but
that will in fact make it MUCH MORE COMPLEX.

Excel is a spreadsheet. Access is a relational database environment. *They are
very different*.

Good design for a spreadsheet is almost by definition inappropriate design for
a relational database! In particular, having a different table field for each
day is *simply wrong*, and will make your database much harder to implement
and use.

Stop, step back, and work *with* Access as it was designed (a relational
database using tall-thin normalized tables) rather than forcing it into a
Procrustean bed emulating a spreadsheet.


The words of a WISE man!! Could not have said this better if I read it from
a book! Duplicating what is In Excel is often a problem and Mr Vinson is
kind in saying that it will make "it more complex."

Here is what we did to help solve a similar issue. This may not be the best
way because there are probably many ways to accomplish this, but we know it
works. OUr way does not allow a worker to start in one day and work through
midnight into the next day. We wrote this for a retail operation that opens
8am and closes 6 or so and thus we tailored our solution to the requirement.

We have a temp table that fills and holds the schedule that is being created.
The fields are:

listfields "tbl_temp_Schedule"
!Schedule_ID (autonum)
!Employee_ID (numb)
!1Reason_ID (numb)
!1Begin_DT (DT)
!1End_DT (DT)
!2Reason_ID
!3Reason_ID
!4Reason_ID
!5Reason_ID
!6Reason_ID
!7Reason_ID
!2Begin_DT
!3Begin_DT
!4Begin_DT
!5Begin_DT
!6Begin_DT
!7Begin_DT
!2End_DT
!3End_DT
!4End_DT
!5End_DT
!6End_DT
!7End_DT

listfields "tbl_Appointment_Status"
!Status_ID
!Appointment_Type_ID
!Status
!Fore_color
!Back_Color
!Border_Color
!Notify
!Notify_minutes
!Prompt_Invoice
!Appearance
!Status_Graphic
!Status_Background_ID
!Available
!sys

'We display the colors of the various status on screen in the colors that the
user chooses... you could skip a bunch of the fields below. The notify stuff
is checked by a splash form timer that presents the user with a prompt when
the notify (t/f) is met by the Notify_mins... again... not necessary for you
probably

listfields "tbl_Appointment_Type"
!Appointment_Type_ID
!Appointment_Type (We use this for various TYPES of appointments which
employee schedule is one, dispatch, meeting, convsersation, delivery) User
can not change these
!sys (This is a field that we use so that records are not erased when create
a new "blank" db for a new customer. Have a routine that goes to each table
and only deleted records that are sys=false, thus you probably would not need
the "sys" field.

There is a bound form with fields in the detail area with the employee name
and then basically laid out with 7 columns of three rows consisting of the
reason and begin and end_DT and the record source is a qry which match the
temp_sch table above (not really rows and column, but controls [combo and
text] in a column/row looking format)

SELECT tbl_Contact.Contact_Name, tbl_temp_Schedule.*
FROM (tbl_temp_Schedule INNER JOIN tbl_Contact ON tbl_temp_Schedule.
Employee_ID = tbl_Contact.Contact_ID) INNER JOIN tbl_Contact_Type_Employee ON
tbl_Contact.Contact_ID = tbl_Contact_Type_Employee.Contact_ID
ORDER BY tbl_Contact.Contact_Name;

the column / row are 1 to 7 respectively like this
1Reason_ID
1Begin_DT
1End_DT

The reason_ID field is a Combo Box which has a rowsource that is a query of a
STATUS table
SELECT tbl_Appointment_Status.Status_ID, tbl_Appointment_Status.Status
FROM tbl_Appointment_Status
WHERE (((tbl_Appointment_Status.Appointment_Type_ID)=4));

Type_ID=4 just happens to be our Employee Schedule type. Delivery is 1,
dispatch is 2 and so on.

Once the temp sched is filled with values and confirmed, the user can then
click a command button which adds the records, overwritting any previous
"date" in the employees records. We basically run the schedule based on the
Sunday of the week the data falls in, which allows people to create a
schedule from Tuesday to the following Monday or any other date range.

code to add is this

rsttmp.Open "tbl_temp_schedule", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
Dim rstSched As New ADODB.Recordset
DoCmd.RunSQL "DELETE * FROM tbl_contact_type_Employee_schedule WHERE
Datevalue(Begin_DT)>=#" & DT & "# AND Datevalue(Begin_DT)<#" & DateAdd("ww",
1, DT) & "# AND MarketID=" & Me.cmbMarket.Column(0)
rstSched.Open "tbl_contact_type_Employee_schedule", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
Do Until rsttmp.eof
For i = 1 To 7
If Len(rsttmp(i & "Begin_DT") & "") > 0 Or rsttmp(i & "Reason_ID") =
3 Or rsttmp(i & "Reason_ID") = 4 Then
rstSched.AddNew
rstSched!Employee_ID = rsttmp!Employee_ID
rstSched!Status_ID = rsttmp(i & "Reason_ID")
rstSched!Begin_DT = Nz(rsttmp(i & "Begin_DT"), 0)
rstSched!End_DT = Nz(rsttmp(i & "End_DT"), 0)
rstSched!DayOfWeek = WeekDay(rstSched!Begin_DT, vbSunday)
rstSched!ScheduleSunday = DateValue(DateAdd("d", -(rstSched!
DayOfWeek - 1), rstSched!Begin_DT))
rstSched!MarketID = Me.cmbMarket.Column(0)
If Not rstUpdate(rstSched) Then GoTo exithere
End If
Next i
rsttmp.MoveNext
Loop

this deletes previous set times in the data and fills in the new information.
Again, we found doing it this way allows the user to create a schedule for
Monday through the next Sunday (7 days) and then open the form back up and
select Thrs through Weds and have the values that were already entered appear
and store the new ones, plus it allows printing any 7 day work schedule, no
matter which starting day they pick.

Just wanted to give you a taste of what you might be in for. As one clever
person already pointed out he would rather write a program that takes in agg
prod by weight and sends it out by size... I concur!!!

Hope the above is not too much, but some assistance in how you might be able
to attact your problem.
 

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