[AccessD] Continue Incrementing

Gustav Brock gustav at cactus.dk
Tue Jul 22 11:38:35 CDT 2003


Hi Virginia

It looks like you don't save the new document number ....

/gustav


> When I open my form and add a new record and (say there is already a record
> in the table "BOM-2601-0010"), the next number given is correct
> ("BOM-2601-0011").
 
> However, if I add another record and use the same prefixes as before
> "BOM-2601"......the next number given is the same as the previous
> ("BOM-2601-0011"). For some reason, I can only get it to increment one time
> only and that's all.
 
> Is there something I can insert in the following statement (which is a
> doubleclick event that assigns the Document Number), which tells it to
> continue incrementing even though the prefixes are the same?
 
> ******************************
> Private Sub DocumentNumber_DblClick(Cancel As Integer)
> Dim intMax As Integer, strPrefix As String
 
> If Me.DocumentNumber = "" Or IsNull(Me.DocumentNumber) Then
> strPrefix = Me.[cboDocType].Column(0) & "-" & Me.cboWBSCodesSelect & "-"
 
> If DCount("DocumentNumber", "DocumentList", "Mid([DocumentNumber],6,4)='" &
> Me.cboWBSCodesSelect & "'") > 0 Then
> intMax = DMax("Val(Mid([DocumentNumber],11))", "DocumentList",
> "Mid([DocumentNumber],6,4)='" & Me.cboWBSCodesSelect & "'")
 
> Me.DocumentNumber = strPrefix & Format(intMax + 1, "0000")
> Else
> Me.DocumentNumber = strPrefix & "0001"
> End If
> End If
> End Sub



More information about the AccessD mailing list