S
shiro
I have the following code in my form.
It works well,like I want.But I need to
put :
DoCmd.SetWarning False
but don't know where is the correct place,
so that the Access warning will not appear
again.Thank's
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strMessage As String
Dim intResponse As Integer
intResponse = MsgBox("Is the spec correct?", vbYesNoCancel, "Confirm")
Select Case intResponse
Case vbYes
If IsNull(Me.Model) Then
strMessage = strMessage & _
" Enter Model Name" & vbCrLf
End If
If Inputvoltage.Value < 11 Then
strMessage = strMessage & _
" Input correct voltage rate " & vbCrLf
End If
If SpeedMode_opt.Value = 2 Then
Else
If Rotationspeedlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input RPM spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 2 Then
Else
If Freeaircurrentlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input Current spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 2 Then
Else
If Lockcurrentlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input Lock Current spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Rotationspeedlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input RPM spec 2 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Freeaircurrentlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input Current spec 2 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Lockcurrentlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input Lock Current spec 2 " & vbCrLf
End If
End If
If Len(strMessage) = 0 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Else
MsgBox strMessage, vbOKOnly, "Errors Occurred"
End If
DoCmd.SetWarnings False
Case vbNo
If MsgBox("Cancel spec registration? ", vbOKCancel, "Confirm") =
vbOK Then
Me.Undo
End If
Cancel = True
Case vbCancel
Cancel = True
End Select
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub
It works well,like I want.But I need to
put :
DoCmd.SetWarning False
but don't know where is the correct place,
so that the Access warning will not appear
again.Thank's
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strMessage As String
Dim intResponse As Integer
intResponse = MsgBox("Is the spec correct?", vbYesNoCancel, "Confirm")
Select Case intResponse
Case vbYes
If IsNull(Me.Model) Then
strMessage = strMessage & _
" Enter Model Name" & vbCrLf
End If
If Inputvoltage.Value < 11 Then
strMessage = strMessage & _
" Input correct voltage rate " & vbCrLf
End If
If SpeedMode_opt.Value = 2 Then
Else
If Rotationspeedlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input RPM spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 2 Then
Else
If Freeaircurrentlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input Current spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 2 Then
Else
If Lockcurrentlolimit1.Value = 0 Then
strMessage = strMessage & _
" Input Lock Current spec 1 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Rotationspeedlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input RPM spec 2 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Freeaircurrentlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input Current spec 2 " & vbCrLf
End If
End If
If SpeedMode_opt.Value = 1 Then
Else
If Lockcurrentlolimit2.Value = 0 Then
strMessage = strMessage & _
" Input Lock Current spec 2 " & vbCrLf
End If
End If
If Len(strMessage) = 0 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Else
MsgBox strMessage, vbOKOnly, "Errors Occurred"
End If
DoCmd.SetWarnings False
Case vbNo
If MsgBox("Cancel spec registration? ", vbOKCancel, "Confirm") =
vbOK Then
Me.Undo
End If
Cancel = True
Case vbCancel
Cancel = True
End Select
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub