473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

User generated between date parameter

Hi, I'm not a newb to Access but have recently migrated to 2007 and suddenly my method doesn't seem to work. I'm generating a service award report where I need to show only those employees hitting a milestone during a certain period of time. I've had Access calculate the appropriate milestone date, and now I want to pull only those records where the milestone date is within a range of dates that the user enters. Here is an example of my WHERE clause (this is a complex query so I'm not posting all of the SQL):
WHERE (((IIf([LAWSON_EMPLOYEE].[ADJ_HIRE_DATE]>[LAWSON_EMPLOYEE].[DATE_HIRED],DateAdd("yyyy",5,[LAWSON_EMPLOYEE].[ADJ_HIRE_DATE]),DateAdd("yyyy",5,[LAWSON_EMPLOYEE].[DATE_HIRED]))) Between [Please enter start date] And [Please enter end date]) AND ((LAWSON_EMPLOYEE.COMPANY)=10) AND ((LAWSON_PAPOSITION.END_DATE)=#1/1/1700#) AND ((LAWSON_EMPLOYEE.EMP_STATUS) In ("AE","AF","AI","AO","AP","AQ","AR","AT","LD","LN" ,"LP")))
There are then several other iterations (10, 15, 20 years...to 55), each clause is separated by OR.
I would expect the user to enter 01/01/2009 for the start parameter and 12/31/2009 as the end parameter - this method has worked for me before. I've also tried 1/1/2009 to 12/31/2009 and also entering literals #01/01/2009# and #12/31/2009# as values. When entering just dates (without the hash) I get too many records, with the hash I get none. I have verified that the values returned are dates.
Any thoughts or suggestions is appreciated!
Thanks!
Apr 9 '09 #1
2 2037
Thanks, I figured it out on my own. The solution is setting a data type for the parameter.
Apr 9 '09 #2
NeoPa
32,556 Expert Mod 16PB
An alternative would be to put the parameters, in the SQL, into CDate() function calls.

EG.
Expand|Select|Wrap|Line Numbers
  1. WHERE ((DateAdd('yyyy',5,IIf([LAWSON_EMPLOYEE].[ADJ_HIRE_DATE]>[LAWSON_EMPLOYEE].[DATE_HIRED],
  2.                              [LAWSON_EMPLOYEE].[ADJ_HIRE_DATE],
  3.                              [LAWSON_EMPLOYEE].[DATE_HIRED])) Between
  4.         CDate([Please enter start date]) And
  5.         CDate([Please enter end date]))
  6.   AND  (LAWSON_EMPLOYEE.COMPANY=10)
  7.   AND  (LAWSON_PAPOSITION.END_DATE=#1/1/1700#)
  8.   AND  (LAWSON_EMPLOYEE.EMP_STATUS In ('AE','AF','AI','AO','AP','AQ','AR','AT','LD','LN','LP')))
Apr 13 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tony | last post by:
Hey guys, I use Google Groups quite a bit as it is an enormous wealth of information, and now I need some help. I have created a query using parameters to capture a range of date, the date is...
6
by: Christopher Young | last post by:
I have several user controls on a page and I am trying to get information out of them. The postback is being caused on the aspx page and not in the user control. I have tried using a property but...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
4
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
3
by: JoMonto | last post by:
Hello- I have a parameter query that I need to add one more feature to - and I'm stuck. The parameter-query portion is pretty simple, it's based on a "ScreeningDate" field - "Between And " ...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
2
by: Dinsdale | last post by:
We have created a object library that implements the INotifyPropertyChanged.PropertyChanged to bubble changes up to higher level classes. For instance, we have a person class that can have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.