Hi, I have the code below that checks the If condition and returns a msgbox if true. i want to exit the beforeupdate sub when the person clicks ok (ie go back to the form), but it keeps on going through the code even after cancel? Note that I can't rely soley on the required field condition due to other code I need witht he database.
any help appreciated!
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strMsg As String
Forms!Home_Oxygen_Form![Hospital No:].SetFocus
If Forms!Home_Oxygen_Form![Hospital No:] = " " Then
MsgBox "You must enter a Hospital Number", vbOKOnly
Cancel = True
Else
End If
...other code here
any help appreciated!
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strMsg As String
Forms!Home_Oxygen_Form![Hospital No:].SetFocus
If Forms!Home_Oxygen_Form![Hospital No:] = " " Then
MsgBox "You must enter a Hospital Number", vbOKOnly
Cancel = True
Else
End If
...other code here