Hi there,
I was wondering if I could get some advice please on testing code that will only change yearly.
I have created a LogNumber (CustID),
With a customisation of the code that I have found in this forum thank you.
--------------------------------------------------------------------------------------
Option Compare Database
Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(Me![BaseID]) Then
Me![BaseID] = Format(Nz(DMax("[BaseID]", "[tblOEMPublications]"), 0) + 1)
End If
Me![LogNumber] = Format([YearID], "yyyy") & "-" & Format([BaseID], "0000")
End Sub
--------------------------------------------------------------------------------------
The above gives me the below result...
YearID - BaseID
2017-0001
2017-0002
2017-0003
2017-0004
2017-0005 excetra
However in this case I only have two days to wait and test for 2018. But because I have altered the code and did get it to work I may have altered something I shouldn't have and it may have affected the reset of the BaseID back to 2018-0001.
But of course you can't always wait for the year to roll over to check if the code will work.
Is anybody I able to assist with my question it is always greatly appreciated.
Sorry if I have put this in the wrong place.
Thanking you for your assistance.
Wish everyone a Happy New Year.
Ani
I was wondering if I could get some advice please on testing code that will only change yearly.
I have created a LogNumber (CustID),
With a customisation of the code that I have found in this forum thank you.
--------------------------------------------------------------------------------------
Option Compare Database
Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(Me![BaseID]) Then
Me![BaseID] = Format(Nz(DMax("[BaseID]", "[tblOEMPublications]"), 0) + 1)
End If
Me![LogNumber] = Format([YearID], "yyyy") & "-" & Format([BaseID], "0000")
End Sub
--------------------------------------------------------------------------------------
The above gives me the below result...
YearID - BaseID
2017-0001
2017-0002
2017-0003
2017-0004
2017-0005 excetra
However in this case I only have two days to wait and test for 2018. But because I have altered the code and did get it to work I may have altered something I shouldn't have and it may have affected the reset of the BaseID back to 2018-0001.
But of course you can't always wait for the year to roll over to check if the code will work.
Is anybody I able to assist with my question it is always greatly appreciated.
Sorry if I have put this in the wrong place.
Thanking you for your assistance.
Wish everyone a Happy New Year.
Ani