I'm trying to work out how to format a custom primary key using the current year as part of the key. I've copied code which I use 'OnCurrent' for the form. The code I've copied is:
Private Sub Form_Current()
If Me.NewRecord Then
Me!RDNo = Format(Nz(DMax( "val([RDNo])", "TblDocumentReq uests"), 0) + 1, "000000")
End If
End Sub
What this should do (based on what it does in my other table) is automatically update the primary key plus one of whatever the last number used was. However, I want is the primary key to read as "RD08-001" (with the 08 being the current year and the 001 to be the bit updated automatically). I've tried every which way to update the code to do this but I just can't get it to work. Please help!!
Private Sub Form_Current()
If Me.NewRecord Then
Me!RDNo = Format(Nz(DMax( "val([RDNo])", "TblDocumentReq uests"), 0) + 1, "000000")
End If
End Sub
What this should do (based on what it does in my other table) is automatically update the primary key plus one of whatever the last number used was. However, I want is the primary key to read as "RD08-001" (with the 08 being the current year and the 001 to be the bit updated automatically). I've tried every which way to update the code to do this but I just can't get it to work. Please help!!
Comment