I have tried to increment an ID if it already exists without much luck. The current code executes on the Before update event on my sbjRELATION field. I'm basing a new ID on an old one so if I have a person with two sons then I want to take their id of "10000" and have "1000011" for the first son and "1000012" for the second son. Problem is not duplicating ids. I have my form increment upon error but this seems inefficient. Is there a way to check an id while you're still in the record to have it increment until it finds a unique one in the sequence?
Public Sub create_id()
Select Case sbjRELATION
'these are many different relations to original subjects
'each group of 10 represents a different kind of relation
Case "Spouse"
Me.sbjHCID = Me.sbjID & "01"
Case "Son"
Me.sbjHCID = Me.sbjID & "11"
Case "Daughter"
Me.sbjHCID = Me.sbjID & "21"
Case "Niece"
Me.sbjHCID = Me.sbjID & "31"
Case "Nephew"
Me.sbjHCID = Me.sbjID & "41"
Case "Mother"
Me.sbjHCID = Me.sbjID & "51"
Case "Father"
Me.sbjHCID = Me.sbjID & "61"
Case "Grandmother"
Me.sbjHCID = Me.sbjID & "71"
Case "Grandfather"
Me.sbjHCID = Me.sbjID & "81"
Case "Other"
Me.sbjHCID = Me.sbjID & "91"
End Select
End Sub
Public Sub create_id()
Select Case sbjRELATION
'these are many different relations to original subjects
'each group of 10 represents a different kind of relation
Case "Spouse"
Me.sbjHCID = Me.sbjID & "01"
Case "Son"
Me.sbjHCID = Me.sbjID & "11"
Case "Daughter"
Me.sbjHCID = Me.sbjID & "21"
Case "Niece"
Me.sbjHCID = Me.sbjID & "31"
Case "Nephew"
Me.sbjHCID = Me.sbjID & "41"
Case "Mother"
Me.sbjHCID = Me.sbjID & "51"
Case "Father"
Me.sbjHCID = Me.sbjID & "61"
Case "Grandmother"
Me.sbjHCID = Me.sbjID & "71"
Case "Grandfather"
Me.sbjHCID = Me.sbjID & "81"
Case "Other"
Me.sbjHCID = Me.sbjID & "91"
End Select
End Sub