J
James
I'm sure there is a simple answer to this but I just can't get my head
around it. I've got an annual leave database and am having trouble
querying for records.
In my leave table I have two fields [leave_start] and [leave_end]. Both
are date/time fields and are formatted dd/mm/yy. On a form
[Switchboard] I have two unbound controls [date1] and [date2] formatted
as dd/mm/yy.
I would like the users to enter dates in [date1] and [date2] to
retrieve annual leave records where people are on leave during that
period. I've got a command button that runs a query which includes
[date1] and [date2] but just cannot get the criteria in my query right.
I've tried the following in my query:
Where [leave_start]>=([Forms]![Switchboard]![Date1]) and
[leave_end]<=[Forms]![Switchboard]![Date2]
If for example [date1]=#21/08/06# and [date2]=#23/08/06# the above
wouldn't work for someone who is on leave 01/08/06-31/08/06 because the
[leave_start] is not after [date1] but that person would actually be on
leave during the specified period. I have also tried various other
permutations but with no luck.
I'm not entirely sure that [leave_start] needs to be involved in the
criteria at all but excluding it would give me all records going back
in time and I do need some kind of starting point based on the dates
entered on the form.
Any help would be greatly appreciated ;D)
Thanks
James
around it. I've got an annual leave database and am having trouble
querying for records.
In my leave table I have two fields [leave_start] and [leave_end]. Both
are date/time fields and are formatted dd/mm/yy. On a form
[Switchboard] I have two unbound controls [date1] and [date2] formatted
as dd/mm/yy.
I would like the users to enter dates in [date1] and [date2] to
retrieve annual leave records where people are on leave during that
period. I've got a command button that runs a query which includes
[date1] and [date2] but just cannot get the criteria in my query right.
I've tried the following in my query:
Where [leave_start]>=([Forms]![Switchboard]![Date1]) and
[leave_end]<=[Forms]![Switchboard]![Date2]
If for example [date1]=#21/08/06# and [date2]=#23/08/06# the above
wouldn't work for someone who is on leave 01/08/06-31/08/06 because the
[leave_start] is not after [date1] but that person would actually be on
leave during the specified period. I have also tried various other
permutations but with no luck.
I'm not entirely sure that [leave_start] needs to be involved in the
criteria at all but excluding it would give me all records going back
in time and I do need some kind of starting point based on the dates
entered on the form.
Any help would be greatly appreciated ;D)
Thanks
James