I have a drop down list that takes a "Stock Type" and then assigns a new code based on that stock type to a field called "Stock ID".
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 "SectionCodeQue ry" that filters by Stock Type based on the same form.
[code=vb]Private Sub Stock_Type_Afte rUpdate()
Dim strProdCode As String
Dim strCriteria As String
If Me.NewRecord Then
strProdCode = Me.Stock_Type.V alue
'Increment the lngNum field by One, if field is Null, set as 0 then add 1
Me!CodeNumber = Nz(DMax("Right( strID,4)", "SectionCodeQue ry"), 0) + 1
'Customize the ID then attach the incremented
Me!Stock_ID = Me.Stock_Type.V alue & "-" & Format(Me!IngNu m, "0000")
Else
Me!Stock_ID = Me!Stock_ID
End If
End Sub[/code]
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 "SectionCodeQue ry" that filters by Stock Type based on the same form.
[code=vb]Private Sub Stock_Type_Afte rUpdate()
Dim strProdCode As String
Dim strCriteria As String
If Me.NewRecord Then
strProdCode = Me.Stock_Type.V alue
'Increment the lngNum field by One, if field is Null, set as 0 then add 1
Me!CodeNumber = Nz(DMax("Right( strID,4)", "SectionCodeQue ry"), 0) + 1
'Customize the ID then attach the incremented
Me!Stock_ID = Me.Stock_Type.V alue & "-" & Format(Me!IngNu m, "0000")
Else
Me!Stock_ID = Me!Stock_ID
End If
End Sub[/code]
Comment