创建计数每5个数字的计数器

时间:2015-06-30 15:35:12

标签: vba ms-access counter

我有一个标有文本框,"批号"在一种称为“#34;接收检查表”的形式中。我的用户必须从我们公司收到的材料中输入批号。我希望检查员检查每个第5批号。这是我的代码:

Private Sub Lot_Number_AfterUpdate()

    Dim x As Integer

    x = 0

    If EndsWith(x) Then
    MsgBox "MUST PERFORM SPECTROMETER TEST!!!!!"
    Me.Lot_Number.SetFocus
    Exit Sub
    End If

End Sub

1 个答案:

答案 0 :(得分:1)

试试这个 - 并礼貌地向用户说明:

Private Sub Lot_Number_AfterUpdate()

    Dim Lot As Integer
    Dim Sec As Integer

    Sec = Second(Time) \ 2    
    Lot = Val(Right(Nz(Me!Lot_Number.Value), 1))
    If Lot Mod 5 = Sec Then
        MsgBox "Please perform spectrometer test.", vbInformation + vbOkOnly, "Inspector Check"
        Me!Lot_Number.SetFocus
    End If

End Sub