Gustav Brock
gustav at cactus.dk
Wed Jul 23 04:47:30 CDT 2003
Hi Virginia I think so (not quite sure how your form is working). /gustav > Do you mean it has to save the record first? Even if it is adding the > document number to the table? > -----Original Message----- > From: Hollis,Virginia [mailto:HollisVJ at pgdp.usec.com] > Sent: Tuesday, July 22, 2003 1:09 PM > To: 'Access Developers discussion and problem solving' > Subject: RE: [AccessD] Continue Incrementing > 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