Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression for form to find highest # less than a designated amount 1

Status
Not open for further replies.

IDilbert6

Technical User
Apr 29, 2004
5
US
Our staff forgot to start renumbering batches for then new fiscal year. Now I want to start with batch 1 and auto-increment batch numbers up by 1 from there, while keeping the batches already in the database that start 600. I have used a formula in the past that searched for the Max and added one, but now I need to do that and ignore the batch numbers that start with 600 and higher. Here is the formula I used successfully before:
=IIf(IsNull(DMax("[BatchNumber]","[tblPVBatchLog]")),1,DMax("[BatchNumber]","[tblPVBatchLog]"))+1

How do I include the "but < 600" in here?

Thanks much.
 
This seems to me a recipe for disaster, however, this is how it works:
[tt]=IIf(IsNull(DMax("[BatchNumber]","[tblPVBatchLog]")),1,DMax("[BatchNumber]","[tblPVBatchLog]","[BatchNumber]<600"))+1[/tt]
 
Why not simply this ?
=Nz(DMax("BatchNumber","tblPVBatchLog","BatchNumber<600"),0)+1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks so much, PHV! You simplified and corrected my expression in one fell swoop - it works perfectly now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top