The Idea is to have XXX-0001 as the first ID and XXX-0002 as the second. Then you could have a BXA-001 as well. I have done this several times before but now I get an error when I try.
Run-Time Error '2001'
You Canceled the previous operation.
Code is show here.
I have a query "SectionCodeQuery" that filters by Stock Type based on the same form.
Expand|Select|Wrap|Line Numbers
- Private Sub Stock_Type_AfterUpdate()
- Dim strProdCode As String
- Dim strCriteria As String
- If Me.NewRecord Then
- strProdCode = Me.Stock_Type.Value
- 'Increment the lngNum field by One, if field is Null, set as 0 then add 1
- Me!CodeNumber = Nz(DMax("Right(strID,4)", "SectionCodeQuery"), 0) + 1
- 'Customize the ID then attach the incremented
- Me!Stock_ID = Me.Stock_Type.Value & "-" & Format(Me!IngNum, "0000")
- Else
- Me!Stock_ID = Me!Stock_ID
- End If
- End Sub