If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Criteria using DateDiff function in SELECT Query.
I have a query that used te DateDiff function.
The purpose of the query is to show the records that are older then 30 days up until 120 days. I'm using this in the query: dayselapsed: DateDiff("d",[POdate],Now()) and for the criteria for the field dayselapsed I have 30 and =120. Is there a way so that my users can specify these numbers by themselves? So that each time you run the query the system aks you enter the period and whereby you then enter the nrs. So for example if you want to see the records that are older then 1 day up until 60 days you would enter 1 and 60. Is this technically possible using a SELECT QUERY??? THANKS FOR ANY SUGGESTIONS... |
#2
|
|||
|
|||
Check Access HELP on "parameter query".
Basically, you'll be replacing your criterion statement with something like: [Enter 'low' days] And = [Enter 'high' days] Note that this does NOT give you a mechanism for validating that: 1. a number was entered (unless you also set the parameter type in the query) 2. a number was entered in both 3, the first number is smaller than the second To do these things, I'd suggest creating a form you use to gather these, use the events for the form and the controls to ensure these validation rules are followed, and then refer to the form's controls in your criterion statement, something like: Forms!YourFormName!YourLowestDaysControlName And = Forms!YourFormName!YourHighestDaysControlName (beware of wordwrap in email) -- Good luck Jeff Boyce Access MVP |
#3
|
|||
|
|||
This does not work, I have already tried this before.
It is probably due to the fact that I'm using the DateDiff function in the query. Thanks anyway.... -----Original Message----- Check Access HELP on "parameter query". Basically, you'll be replacing your criterion statement with something like: [Enter 'low' days] And = [Enter 'high' days] Note that this does NOT give you a mechanism for validating that: 1. a number was entered (unless you also set the parameter type in the query) 2. a number was entered in both 3, the first number is smaller than the second To do these things, I'd suggest creating a form you use to gather these, use the events for the form and the controls to ensure these validation rules are followed, and then refer to the form's controls in your criterion statement, something like: Forms!YourFormName!YourLowestDaysControlName And = Forms!YourFormName!YourHighestDaysControlName (beware of wordwrap in email) -- Good luck Jeff Boyce Access MVP . |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bug in access calling function from insert into query??? | Michael | Running & Setting Up Queries | 3 | August 26th, 2004 04:51 PM |
UNION Query with Criteria | Dkline | Running & Setting Up Queries | 1 | August 4th, 2004 09:15 PM |
Struggling with MS Query... | Alex | General Discussion | 5 | July 6th, 2004 11:46 AM |
Delete Query based on result of select query | John Finch | Running & Setting Up Queries | 1 | July 2nd, 2004 05:47 PM |