I think the best bet would be to create a VBA module that runs each time the database is opened. Something like this:
Create a new module in the Visual Basic editor and copy the global variables into it.
------
Global GlobalDat, GlobalRecNr
------
On your start form double click the "on open" statement in the properties dialog under the action tab, switch to the visual basic editor. Enter the following code:
-----------
Private Sub Form_Open(Cancel As Integer)
Dim Dba As DAO.Database, Rst As DAO.Recordset
Dim Dat
Set Dba = CurrentDb
Set Rst = Dba.OpenRecordset("TABLENAME")
Dat=year(Date)
Rst.MoveLast
If left(Rst("FIELDNAME"),4) < Dat then
GlobalDat = Dat
GlobalRecNr = "00001"
Else
GlobalDat = Left(Rst("FIELDNAME"),4)
GlobalRecNr = Right(Rst("FIELDNAME"),5)
End If
End Sub
…….
You will need to modify or write code to increment the record number each time a new record is created:
Taking for granted that you have added a button, using the buttons assistant, to create the new record. In the development view of the form, select the add new record button, go to the properties dialog action tab and click on the "…" to the right of the line, this brings you into the VB editor. After the " DoCmd.GoToRecord , , acNewRec" statement add the following:
If GlobalRecNr <>"00001" Then
GlobalRecNr = GlobalRecNr + 1
End If
Me.FIELDNAME = GlobalDat & GlobalRecNr
I hope this works for you