Home > other >  Numeration in MS Access
Numeration in MS Access

Time:01-19

please have at look on my issue.

I try to assign a autonumber with increment plus 1 for each new record in [No] as integer. I use following code, but it doesn`t works correctly, and records stops calculated.

Private Sub Ser_AfterUpdate()
If Ser = "O" Then
    Dim MyYear, varLast
        MyYear = Year(Date)
        Yr = Right(MyYear, 2)
        varLast = DLast("No", "NotamT")
        No = varLast   1
        Types.Requery
    Else
    MsgBox "WRONG NOTAM SERIES"
    End If
End Sub

CodePudding user response:

Try Dmax function instead, also ensure the field datatype is integer not text.

CodePudding user response:

It is not very clear, what you try to do, but it could be something like this:

Private Sub Ser_AfterUpdate()

    If Ser = "O" Then
        Me!Yr.Value = Year(Date) Mod 100
        Me!No.Value = Nz(DMax("No", "NotamT"))   1
        Me!Types.Requery
    Else
        MsgBox "WRONG NOTAM SERIES"
    End If

End Sub
  •  Tags:  
  • Related