|
在排单窗体输入排单批次值PlanBath时,对记录进行检查,判断同一天同一台机不能重复PlanBath值的输入。下面的代码放在PlanBath 更新后事件里。发现会出错,有时候不能检查出同一天同一台机已经输入同样的PlanBath值,没有反应。请高手帮忙看看那里的问题?谢谢!
排单顺序: PB01 => PB02 => PB03 => PB04 同一天DyelotDate同一台机MachineName不能重复PlanBath值的输入。
Private Sub PlanBath_AfterUpdate()
Dim rs As New ADODB.Recordset
rs.Open "SELECT Tbl_DyeHistory.DyelotDate, Tbl_DyeHistory.MachineName, Tbl_DyeHistory.PlanBath FROM Tbl_DyeHistory WHERE Tbl_DyeHistory.DyelotDate=# " & Me.DyelotDate.Value & " # ", CurrentProject.Connection, adOpenStatic, adLockReadOnly
Do While Not rs.EOF
If rs.RecordCount > 0 Then
If Me.MachineName.Value = rs("MachineName") And Me.PlanBath.Value = rs("PlanBath") Then
MsgBox "系统检测到当天" & Me.MachineName.Value & " 机台的这个" & Me.PlanBath.Value & " 已经存在," & "请核对后重新输入新的PlanBath ", vbInformation, "提示重复"
Me.PlanBath = Null
Me.PlanBath.SetFocus
Exit Sub
Else
End If
End If
rs.MoveNext
Loop
End Sub |
|