Using Prior Data for a Field Default Value

R

rj

I have a form that inputs weekly Order data. Besides the Customer Name and
Date, (there's a start date and end date on the form - a Monday and the
following Sunday), there are 30 items on the Order Form (each chosen from a
combo box) but from week to week, only a few of them change. I would like the
default for the fields in the form to be the previous week's values so only
the changed fields need to be entered. Perhaps a DLookup method? Thank you
for your help.
 
S

Stefan Hoffmann

hi,
I have a form that inputs weekly Order data. Besides the Customer Name and
Date, (there's a start date and end date on the form - a Monday and the
following Sunday), there are 30 items on the Order Form (each chosen from a
combo box) but from week to week, only a few of them change. I would like the
default for the fields in the form to be the previous week's values so only
the changed fields need to be entered. Perhaps a DLookup method?
Use a "Add" button to copy the last week record.

mfG
--> stefan <--
 
K

Klatuu

Below are two functions. One for returning the monday of the week and one
for returning the sunday of the week. If you want the previous week's dates,
call them like this:

weekstartdate(dateadd("ww",-1,date))
weekenddate(dateadd("ww",-1,date))

Function WeekEndDate(BaseDate As Date) As Date
'Dave Hargis 9/04
'Returns the last date of the accounting week for the date entered)

WeekEndDate = DateAdd("ww", 1, DateAdd("d", vbSunday - DatePart("w",
BaseDate), BaseDate))
End Function

Function WeekStartDate(BaseDate As Date) As Date
'Dave Hargis 9/04
'Returns the first date of the accounting week for the date entered)

WeekStartDate = DateAdd("d", vbMonday - DatePart("w", BaseDate), BaseDate)
End Function
 
Top