[AccessD] Continue Incrementing

Hollis,Virginia HollisVJ at pgdp.usec.com
Tue Jul 22 13:08:59 CDT 2003


Well, the document number (i.e. BOM-2601-0010) populates the appropriate
field in the table.  I thought that the coding would look at the table field
and see that there is this document number already there and increment by
one.

Va.

-----Original Message-----
From: Gustav Brock [mailto:gustav at cactus.dk]
Sent: Tuesday, July 22, 2003 11:39 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Continue Incrementing


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

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list