Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2005

Tip: Looking for answers? Try searching our database.

Using date criteria more than once

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob - 19 May 2005 07:00 GMT
Hi,

I need to enter a date via a prompt that is then used by other field
criteria - is this possible?

I have a query that prompts for several dates, these prompts are set up in
field criteria e.g. field name PerEnd has its criteria set as [Enter Period
Date] and the user enters for example 26/03/2005.  What then happens is that
3 more date prompts are requested for other fields, one requires the same
date 26/03/2005, one requires a date one day later 27/03/2005 and one
requires a date one day less 25/03/2005.

Is it possible to capture these 4 date from simply entering one date?

Thanks, Rob
tina - 19 May 2005 08:07 GMT
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
John Spencer (MVP) - 21 May 2005 21:25 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.