PDA

View Full Version : Incremetning Outline Numbers(Sections)



JustJerry
09-01-2006, 07:56 AM
Trying to find out if there is an easy way to increment numbers in the following way; for example 4.1.1.1, 4.1.1.2, etc.

I have a table created in the following manner:

LineSub415ID (Primary Index) (AutoNumber)
LineID (Number) <this field will link one to many to another table>
S415A (Text) This field will be the incrementing field
Length (Text) Field to store Length of Line

Basically, S415A will default to 4.1.5.1, then if there are more 'Lines' to add, the field S415A will automatically increment to 4.1.5.2.

OBP
09-01-2006, 08:57 AM
Yes I have already written some VBA for this for someone incrementing a field recording change version numbers.
I will see if I can find the thread.

JustJerry
09-01-2006, 09:03 AM
Thanks OBP. I tried a search, but must not have typed in the correct phrasing

OBP
09-01-2006, 09:53 AM
It may not have been on this forum.:)
I have found one of my databases that uses similar logic and here is the VBA

Dim oldnumber As String, zeroes As String
zeroes = "0000000"
oldnumber = Me.Tracking_Number
oldnumber = oldnumber + 0.01
MsgBox oldnumber
If Len(oldnumber) < Len(zeroes) Then
oldnumber = Left(zeroes, (Len(zeroes) - Len(oldnumber))) & oldnumber
DoCmd.OpenForm "Transfer Record", , , , , acHidden
DoCmd.GoToRecord acForm, "Transfer Record", acFirst
Forms![Transfer Record]![EstimateID] = Me.EstimateID
DoCmd.Close acForm, "Transfer Record"
DoCmd.OpenQuery ("MAIN TABLE Transfer")
If Len(Me.Tracking_Number) < 7 Then
Me.Tracking_Number = Me.Tracking_Number & ".01"
Else
Me.Tracking_Number = oldnumber
End If
End If

If this doesn't help you, post a zipped copy of the database on here and I will write it for you.