Hello,
I have three fields that are: Standard_Number + FY + Unqiue_Number they make up a file number. These three fields are stored separately in the table as well are concatented on before update into a field called regional_number. My problem is that the user needs to be able to press a button and it will give the next sequential number. The last field must always be 4 digits. I have it set up that it will will place the leading zeros if need be. I have following code:
Private Sub MakeNumber()
DoCmd.GoToRecord , "", acNewRec
If Me.NewRecord Then
Me.Unique_Number = DLookup("Format(Max(CInt([DAA-MasterTable].Unique_Number))+1,'0000')", "DAA-MasterTable")
End If
DoCmd.GoToControl "Employee_Name"
End Sub
The button will run this code and it will insert the next number in the unique_number field. This is great!! But the problem comes into play when the new fiscal year comes upon us and the number needs to begin over again. For instance, currently the numbering would be AL-04-0080. But after 0080 here comes (and then the next FY comes upon us) FY 05 so it should be AL-05-0001. But what happens is the number will show up is AL-05-0081. The code is only looking at the unique_number portion...Is there a way I can get it to look at the whole number??
Thanks,
---roystreet
I have three fields that are: Standard_Number + FY + Unqiue_Number they make up a file number. These three fields are stored separately in the table as well are concatented on before update into a field called regional_number. My problem is that the user needs to be able to press a button and it will give the next sequential number. The last field must always be 4 digits. I have it set up that it will will place the leading zeros if need be. I have following code:
Private Sub MakeNumber()
DoCmd.GoToRecord , "", acNewRec
If Me.NewRecord Then
Me.Unique_Number = DLookup("Format(Max(CInt([DAA-MasterTable].Unique_Number))+1,'0000')", "DAA-MasterTable")
End If
DoCmd.GoToControl "Employee_Name"
End Sub
The button will run this code and it will insert the next number in the unique_number field. This is great!! But the problem comes into play when the new fiscal year comes upon us and the number needs to begin over again. For instance, currently the numbering would be AL-04-0080. But after 0080 here comes (and then the next FY comes upon us) FY 05 so it should be AL-05-0001. But what happens is the number will show up is AL-05-0081. The code is only looking at the unique_number portion...Is there a way I can get it to look at the whole number??
Thanks,
---roystreet