Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date parameter form

Status
Not open for further replies.

HighLightUK

Technical User
Mar 4, 2003
20
GB
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...
 
Take a look at the 2nd parameter of the Weekday function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top