Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me.StudentID = "VIP001"
Else
Me.StudentID = "VIP" & Format(DMax("Mid([StudentID],4)", "tblStudents") + 1, "000")
End If
End If
End Sub
Replace tblStudents with the actual name of the Table that holds the data. Ditto with StudentID, unless that is the actual Field Name.
Being in the Form_BeforeUpdate, the number will increment at the last possible second before the Record is saved. This sounds like a single-user app, from your description, and so it doesn't really matter, but in a multi-user app you want the number to be assigned at the very last moment, to decrease the possibility of two users getting the same number; it's probably good to get in the habit of doing it like this.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007