Dmax reset (1 Viewer)

Abacus

New member
Local time
Today, 02:35
Joined
Oct 11, 2019
Messages
3
Hi,

I have a system where I have joined fields together to make a unique numbering system:

QuoteYear / QuoteMonth / Quoter / QuoteNo
2019 11 SC DMAX Increment

Joined together it results are 2019-11-SC-0001

This works great however what I would like to do is have the QuoteNo field go back to 1 after a new month followed obvioulsy by the year change.

I would also like this for each member of the sales staff. So if SC starts off at 2019-11-SC-0001 the ML would start 2019-11-ML-0001

I tried a sample before putting into my database and it seemed to work however no in the main system the DMAX just rolls on regardless for everyone.:banghead:

My code is on current:
If Me.QuoteNo = 0 Then
Me.QuoteNo = Nz(DMax("QuoteNo", "Quote Register", Format(QuoteMonth, "mm") = Format(Date, "mm")), 0) + 1
Me.QuoteNo = Nz(DMax("QuoteNo", "Quote Register", Format(QuoteYear, "yyyy") = Format(Date, "yyyy")), 0) + 1
End If


Can anyone assist.

I'm not an experienced programmer so any help would really be appreciated.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:35
Joined
Oct 29, 2018
Messages
21,453
Hi. Don't you want to combine all the criteria in one DMax()?
 

Abacus

New member
Local time
Today, 02:35
Joined
Oct 11, 2019
Messages
3
Hi

Yes if I could that would be great, sorry I didn't know that would be possible. Could you provide an example I could try and work with, thanks :)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:35
Joined
Oct 29, 2018
Messages
21,453
Hi

Yes if I could that would be great, sorry I didn't know that would be possible. Could you provide an example I could try and work with, thanks :)
It might look something like this.

Code:
Me.QuoteNo=Nz(DMax("QuoteNo","Quote Register","Staff='" & Me.Staff _
& "' AND QuoteMonth=" & Month(Date()) _
& " AND QuoteYear=" & Year(Date())),0)+1
 

Abacus

New member
Local time
Today, 02:35
Joined
Oct 11, 2019
Messages
3
Thank you so much, I'll give this a try and let you know how I get on.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:35
Joined
Oct 29, 2018
Messages
21,453
You're welcome. Good luck.
 

Users who are viewing this thread

Top Bottom