let's assume:
your form name is TESTFORM
your plant name field is called PLANT
the table storing your information is called TblTest
The field storing your label in is called MOC
the code to create your number would be something like
Code:
Dim sMOC
Dim sMaxMOC
sMOC = Plant & "-" & DatePart("yyyy", Date)
sMaxMOC = DLookup("Max([MOC])", "tblTest", "left([MOC], 6) = '" & sMOC & "'")
If IsNull(sMaxMOC) Then
sMOC = sMOC & Right("0" & DatePart("m", Date), 2) & Right("0" & DatePart("m", Date), 2) & "0001"
Else
sMOC = sMOC & Right("0" & DatePart("m", Date), 2) & Right("0" & DatePart("m", Date), 2) & Right("0000" & CInt(Right(sMaxMOC, 4)) + 1, 4)
End If
MOC = sMOC
you'd have to run this whenever you changed the plant