HighLightUK
Technical User
Hi,
I have a form with a calendar control which I want the user to select a date from the calendar and then run a report. This works fine.
When the user selects the date, I need the command button to identify the Monday and Friday either side of the selection and pass this to the report in the form of a parameter value.
e.g. Selecting 09/12/04 (uk date) returns 06/12/04 for dtBegWeek and 10/12/04 for dtEndWeek.
Clicking on 11 or 12/11/04 (Sat and Sun) would also return the above values.
I have been playing around with DateAdd but my vba is a bit rusty and can't get the damn thing to work.
dtEndWeek = DateAdd("d",(7 - weekday(Date), Date)
dtBegWeek = DateAdd("d", -6, dtEndWeek)
Gives me values for the current week starting with a Saturday and ending with a Sunday, which I need to ignore.
Any help appreciated...
I have a form with a calendar control which I want the user to select a date from the calendar and then run a report. This works fine.
When the user selects the date, I need the command button to identify the Monday and Friday either side of the selection and pass this to the report in the form of a parameter value.
e.g. Selecting 09/12/04 (uk date) returns 06/12/04 for dtBegWeek and 10/12/04 for dtEndWeek.
Clicking on 11 or 12/11/04 (Sat and Sun) would also return the above values.
I have been playing around with DateAdd but my vba is a bit rusty and can't get the damn thing to work.
dtEndWeek = DateAdd("d",(7 - weekday(Date), Date)
dtBegWeek = DateAdd("d", -6, dtEndWeek)
Gives me values for the current week starting with a Saturday and ending with a Sunday, which I need to ignore.
Any help appreciated...