View Full Version : Code for handling dates


jonnywakey
02-03-2009, 12:50 AM
Hi I am new to this forum but have a small amount of experience with Access.

I am trying to simulate a Gantt chart on a form; I have 10 fields listed on the left hand side of the form (Task), each with a start date and end date next to them!

The Gantt lines are made up of 52 text boxes (1 for each week of year)
above each Gantt box is a label [Label65] with the date of each week ending.

I have tried code in each box to enable the result "True" of "False" to be shown, this then enables me to Conditionally format the box and text to black if criteria is met.

My problem is I can't get the code to work for the start date and end date in each weekly box, it only works on the start date.

I want to turn the text box black if the start dates and finish dates fall within the week [Label65]

I have tried the following:-

=IIf([Start Date1]=[Label65],"True","False")

this works for the start date but how do i incorporate the finish date?

Thanks for any assistance

Jonny

DCrake
02-03-2009, 01:17 AM
Try:

=IIf([YourDateField]<[YourFinishDate],"True","False")


David

jonnywakey
02-03-2009, 02:54 AM
David, thanks for your tip; it works within reason and has helped me structure the statement better.

My project start date [Start Date1] is 28/12/08
My project finish date [Finish Date1] is 05/02/08

I have now used the following expression:-
=IIf([Start Date1] Between 22-12-8 And 28-12-8,"True","False")

This returns "True" and conditional formatting turns the text box black as desired.

How would the same text box handle the Finish date?

DCrake
02-03-2009, 03:17 AM
Add an And condition to the start date condition

((Start date Between X And Y) and (finish date Between A and B))