[AccessD] Query question ... Finding the proper rate/per date

John Clark John.Clark at niagaracounty.com
Wed Nov 4 10:52:31 CST 2009


Thanks Stuart, this looks to be exactly what I need. I had to finagle a bit, to fit my query, but it works pretty damn good.
 
However, what I have done in the past, is take the code, from the query, and place it into my form's code, and this doesn't work for this case. I'm guessing that this "TOP" command, only works in queries? If so, I'll have to grab this info out of the query...I've done this in the past, but it has been quite a while, so I'll have to track down the process.
 
Thanks again!

>>> "Stuart McLachlan" <stuart at lexacorp.com.pg> 11/2/2009 3:09 PM >>>
Use TOP 1 for this.

Something like

SELECT TOP 1 Rate
FROM tblMilageRates
WHERE EffectiveDate < [Enter Date] ;
ORDER BY EffectiveDate DESC

-- 
Stuart

On 2 Nov 2009 at 14:14, John Clark wrote:

> So, what I figured on doing...and please correct me, if I am going about
> this the wrong way...is to have a separate table for mileage rate. It
> would have 3 fields, a record ID (probably unneeded), effective date, and
> the rate for that date. I then want the program to look at the date of an
> entry, and match it up w/the proper date from this table.
> 
> I know this doesn't work...already tried it...but here is basically what
> it would be:
> 
> Max( < [Enter Date]) 
> 
> The entered date does indeed bring up the last date & rate entered, but it
> brings up ALL previous entries. So, if I could get the max date, it should
> be the last one...correct? But, this is not proper code.

-- 
AccessD mailing list
AccessD at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/accessd 
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list