Hi,
Well I would write the function to do this:
1) Get the Max value of the ID field.
2) Get a count of the number of records where ID = MaxOfID.
3) If CountOfID < 3 return Max Else return Max + 1.
Public Function NextID() As Long
Dim rs As Recordset, MaxID As Long
Set rs = CurrentDb.OpenRecordset("SELECT Max(Table1.ID) AS MaxOfID FROM Table1"
If Not (rs.RecordCount = 0) Then
rs.MoveFirst
'Nz() Accounts for case of 0 records
MaxID = Nz(rs![MaxOfID], 0)
Set rs = CurrentDb.OpenRecordset("SELECT Count(Table1.ID) AS CountOfID FROM Table1 WHERE (((Table1.ID) = " & MaxID & "

)"
If Not (rs.RecordCount = 0) Then
rs.MoveFirst
If (rs![CountOfID] < 3) Then
NextID = rs![CountOfID]
Else
NextID = rs![CountOfID] + 1
End If
Else
NextID = 0
End If
Else
NextID = 0
End If
rs.Close
End Function
The only thing to note is that I don't believe that you can place user-defined function in the "Default Value" field in the tables design view. However, you can place it in the "Default Value" of the text box on the form - go figure! And depending on your version of Access, you may need to define rs as DAO.Recordset instead of Recordset.
Rob Marriott
rob@career-connections.net