one solution is to run the query from a form, which i'll call
frmQueryCriteria. create an unbound textbox control, which i'll call
txtEndPeriodDate, on the form so your user can enter the date. create three
more textbox controls, i'll call them txtSameDate, txtDayAfter,
txtDayBefore. if you don't want the user to manually enter or change these 3
dates, you can disable and lock the controls, or just make them invisible.
set the ControlSource property of txtSameDate, txtDayAfter, and txtDayBefore
to
=[txtEndPeriodDate]
=[txtEndPeriodDate] + 1
=[txtEndPeriodDate] - 1
respectively. add a command button; in the button's OnClick event, add a
macro or VBA code to open the query (or open a report or another form, bound
to the query - whatever you need).
in the query design view, set the criteria for the date fields as
[Forms]![frmQueryCriteria]![txtEndPeriodDate]
[Forms]![frmQueryCriteria]![txtSameDate]
[Forms]![frmQueryCriteria]![txtDayAfter]
[Forms]![frmQueryCriteria]![txtDayBefore]
respectively. you may have to set the query Parameters (look under Query on
the menu bar, in query design view) for each field to Date/Time, so Access
will assign the correct data type.
hth
> Hi,
>
[quoted text clipped - 11 lines]
>
> Thanks, Rob
Rob - 19 May 2005 08:10 GMT
Thanks Tina, you've certainly given me something to think about, not sure
I'm up to it but will try your suggestion. Rob
> one solution is to run the query from a form, which i'll call
> frmQueryCriteria. create an unbound textbox control, which i'll call
[quoted text clipped - 48 lines]
>>
>> Thanks, Rob
tina - 19 May 2005 08:31 GMT
it's not so bad to set up, looks scarier than it is. just go through it step
by step, and come back with specific questions if i wasn't clear enough on
any points, or if you run into problems. you can do it! :)
> Thanks Tina, you've certainly given me something to think about, not sure
> I'm up to it but will try your suggestion. Rob
[quoted text clipped - 51 lines]
> >>
> >> Thanks, Rob
Easy way to do this is to use the DateAdd function
[Enter Period Date]
DateAdd("d",1,[Enter Period Date])
DateAdd("d",-1,[Enter Period Date])
Since [Enter Period Date] is always the same, Access will ask you only once for
the value you want in [Enter Period Date] and will use that in every instance.
The DateAdd function will add or subtract one day from the date.
> Hi,
>
[quoted text clipped - 11 lines]
>
> Thanks, Rob