Design by Sue
Registered User.
- Local time
- Today, 10:35
- Joined
- Jul 16, 2010
- Messages
- 816
I have a mainform and with a subform. The user makes a selection on the mainform of the pack they want to assign items to. Then the tab to the subform where they select items to add to the pack. When the user returns to the mainform, if the required fields in the subform are not completed, a message box pops up that states "You must enter a value..." because one of the required fields has been left blank. I have added the following code to the Before Update event of the subform and it seems to work correctly ... almost...If the user selects Yes, the subform is cleared and the user can select the new pack on the mainform. If the user selects No, he is returned to the subform to complete the record, but still gets the "You must enter a value" access message. Is there anyway to intercept that message so it doesn't appear, other than to make the fields not required in the table? (I believe I have coded the buttons on the form to avoid saving a record without entering all required fields, but I like the security of the required fields in case I have missed something in the coding)
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.Description) Or Not IsNull(Me.Quantity) Then
If MsgBox("You have not completed your item entry." & vbCrLf & "Do you want to continue and delete this partial record?", vbQuestion + vbYesNo, "Continue Without Saving?") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
DoCmd.SetWarnings True
End If
End If
End Sub
Sue
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.Description) Or Not IsNull(Me.Quantity) Then
If MsgBox("You have not completed your item entry." & vbCrLf & "Do you want to continue and delete this partial record?", vbQuestion + vbYesNo, "Continue Without Saving?") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
DoCmd.SetWarnings True
End If
End If
End Sub
Sue