Can delete

bunji

Registered User.
Local time
Today, 20:15
Joined
Apr 26, 2005
Messages
124
I have a field that if another field matches the criteria then a user must fill in that field. If that makes sense!!

I have some code that if a user exits without entering any information on it asks them if they want to and if not undoes what the user has entered in the form. This works fine however a user can enter something into the field exit the field then go back in and delete it. When the user then goes to exit it doesnt flag up as it thinks it has been updated. Can anyone help with this.

My Code so Far:


Code:
If Me.No2Release = "Cayman Certificate of Release to Service" And Me.Eng2_Approval = "" Then
        If MsgBox("You haven't entered an approval number. Do you want to?", vbQuestion + vbYesNo) = vbYes Then
        Me.AC_Ser_No.SetFocus
        Me.Eng2_Approval.SetFocus
        Else 'user clicked no
        DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
        Me.Base.SetFocus
        End If
    End If

Thanks
 
1, your code is in the wrong event. You need to move the code to the FORM's BeforeUpdate event.
2. You are checking a field for a zero-length-string when you should be checking for null.
3. Then you need to modify it as follows:
Code:
If Me.No2Release = "Cayman Certificate of Release to Service" And (Me.Eng2_Approval = "" Or IsNull(Me.Eng2_Approval))Then
        If MsgBox("You haven't entered an approval number. Do you want to?", vbQuestion + vbYesNo) = vbYes Then
            Cancel = True
            Me.AC_Ser_No.SetFocus
            ' Me.Eng2_Approval.SetFocus '- pick one field to set focus to.
        Else 'user clicked no
            Me.Undo        
        End If
End If
 

Users who are viewing this thread

Back
Top Bottom