DMax()-1???????

babypowdr

New member
Local time
Today, 07:50
Joined
Aug 27, 2003
Messages
5
Can anyone give me the proper syntax to due this?

DMax("[CurrReadDate]", "ReadingTbl", "[AccountNo] =" & Me.AccountNo) - 1

It's not working the way it is above, and I actually need the record right before the one with the most recent date in order to do what it is that I am trying to do.

Thanks,

Mac
 
Mac,

The DMax will return the maximum date, and that minus one will
not give you what you are looking for.

Wayne
 
Okay,

But how do I get to what I'm looking for? Any Help would be appreciated. Thanks,

Mac
 
Mac,

Didn't you download the example on the other thread?

Wayne
 
Totally unrelated to your question, babypowdr, but your signature isn't technically correct.

You are attributing the quote to Willy Wonka and the Chocolate Factory which, to be fair, is half true; the original quote is by Arthur O'Shaughnessy and here it is in its original context.


As for your problem it's probably because your account number is a text field and you are evaluating it as if it were a numerical field.

Code:
[i]whatever = [/i]DMax("[CurrReadDate]", "ReadingTbl", "[AccountNo] = """ & Me.AccountNo & """") - 1
 
Thanks Mile,

The AccountNo is an AutoNumber and with the (-1) he is trying
to get the prior month's date value (the second to most recent
record).

Wayne
 
I downloaded it, and I used the example to figure out the syntax for the DMax() function, but I don't understand how to use the DMax() to get the DateRead and MeterReading from the record just before the last record. In this case that is what I need to do. Because by the time I am entering the current reading, the old record is now the 2nd to last record in the set.

Sorry if my last explanation wasn't as good. I'm working on implementing the DLookup part of the code to do this though.

Thanks for the sample code, and all the help,

Mac
 
You are searching for the maximum date for a given account number and subtracting 1 from the date. Are you then using that date along with the same account number to retrieve the desired record? I presume that there is only a single record for a date within an account number. If that is not true, your logic is faulty.
 

Users who are viewing this thread

Back
Top Bottom