D
Danielle-Taylor
Hello,
I have searched and search all day to find an answer to my query.
I am using MS Access to create a simple database. I have a data entry form
which has some required fields (set in table design). If the user doesn't
fill in the required fields and tries to close the form the first dataerr is
3314 which give isn't very user friendly, then this is followed by dataerr
2169 which asks the user if they want to close the form, if they say yes it
will close and the record will not be saved, if they say yes it returns back
to the form.
My aim is to not display the dataerr 3314 which I have achieved. But I want
to customise dataerr 2169 to say 'There are required fields empty. If you
close the form your record will not be saved. Would you like to close this
form?'
I am struggling on how to code the 'No' answer so it cancels closing the form
and returns to the form like dataerr 2169 would do? Any help would be much
appreciated!
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 3314
Response = acDataErrContinue
Case 2169
Response = acDataErrContinue
If MsgBox ("'There are required fields empty. If you close the form your
record will not be saved. Would you like to close this form?", vbYesNo) =
vbNo Then
'Require code to cancel the close form operation
End If
Case Else
Response = acDataErrDisplay
End Select
End Sub
I have searched and search all day to find an answer to my query.
I am using MS Access to create a simple database. I have a data entry form
which has some required fields (set in table design). If the user doesn't
fill in the required fields and tries to close the form the first dataerr is
3314 which give isn't very user friendly, then this is followed by dataerr
2169 which asks the user if they want to close the form, if they say yes it
will close and the record will not be saved, if they say yes it returns back
to the form.
My aim is to not display the dataerr 3314 which I have achieved. But I want
to customise dataerr 2169 to say 'There are required fields empty. If you
close the form your record will not be saved. Would you like to close this
form?'
I am struggling on how to code the 'No' answer so it cancels closing the form
and returns to the form like dataerr 2169 would do? Any help would be much
appreciated!
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 3314
Response = acDataErrContinue
Case 2169
Response = acDataErrContinue
If MsgBox ("'There are required fields empty. If you close the form your
record will not be saved. Would you like to close this form?", vbYesNo) =
vbNo Then
'Require code to cancel the close form operation
End If
Case Else
Response = acDataErrDisplay
End Select
End Sub