Autonumber addidng on when not saving record

lovett10

Registered User.
Local time
Today, 07:19
Joined
Dec 1, 2011
Messages
150
Autonumber adding on when not saving record

The problem im having is that the autonumber is advancing even if the user doesnt save the record...

e.g. if they begin creating then cancel

this is a problem as the next time they go to use it, it will be out of sync

Code:
Private Sub Command34_Click()
Dim stDocName As String
If IsNull(Me.Engineer1) And Me.Engineer2 & "" <> "" Then
    MsgBox "You Must enter Engineer 1 before you enter Engineer 2", vbExclamation, "Visit Report"
        Exit Sub
ElseIf IsNull(Me.Engineer2) And Me.Engineer3 & "" <> "" Then
    MsgBox "You Must enter Engineer 2 before you enter Engineer 3", vbExclamation, "Visit Report"
        Exit Sub
ElseIf IsNull(Me.Engineer1) And Me.Engineer3 & "" <> "" Then
    MsgBox "You Must enter Engineer 1 before you enter Engineer 3", vbExclamation, "Visit Report"
        Exit Sub
            End If
If IsNull(Me.Text38) Or IsNull(Me.cbrQuoteNum) Or IsNull(Me.TypeOfWorks) Or IsNull(Me.Engineer1) Or IsNull(Me.Customer) Then
 MsgBox "You have not completed all of the required fields!", vbExclamation, "Visit Report"
    Exit Sub
        End If
If MsgBox("Do you want to add another Visit sheet?", vbYesNo, "Additional") = vbYes Then
        DoCmd.RunCommand acCmdSaveRecord
         stDocName = "Visit Form"
    DoCmd.OpenForm stDocName, , , acFormAdd
    Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
DoCmd.OpenForm "HomePage"
End If
End Sub

Thats my code on the save button if it helps :)

Thanks for any help im very confused and feel like :banghead:.
 
Last edited:
Please do a search here on 'autonumber'. There are many post that will tel what the autonumber is for, how it works and what the alternative is if the number needs to be controlled.

Catalina
 
as catalina says, you cannot expect an autonumber to always run in sequence. it may decide to jump to a new value. and it deinitely does "burn" values if you scrap a partly completed entry.

the point is, it should not matter. if maintaining an intant sequence does matter - then you ought to use a different concept, rather than an autonumber
 

Users who are viewing this thread

Back
Top Bottom