Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.Quit and Error Supression

Status
Not open for further replies.

benwah

Technical User
Jun 27, 2001
97
GB
Hi all

I have a form with required fields. I also have a quit button that exits out of Access completly.

Problem is if one of these required fields isnt filled out and the user wants to quit not caring if they loose the information, access gives them an error message they dont understand. I want to replace this error message with my own yes/no msgbox telling them they will loose data and asking if they would like to proceed.

this is the code i use:
#####################################################

Private Sub cmdclose_Click()

On Error GoTo errortrap1

'** if i use docmd.quit it will bypass the error supression. Using Docmd.GoToRecord forces it to the msgbox suppression section. **

DoCmd.GoToRecord , , acFirst



errortrap1:
If MsgBox("Some or all required fields are incomplete. Quiting will result in deleting the current record. Do you wish to proceed?", vbYesNo, "Oh Dear!!") = 6 Then
Resume errorexit1

Else
Exit Sub
End If

errorexit1:
DoCmd.Quit

exit sub

#####################################################

No matter what i do i still get the default error message. Is there a way around it?

thanks in advance
wah

ps i use the same method when navigating between records and it works fine.

 
oh yeah this is the message i get from access that i dont want:

The Required property for disps.daterec is set to True, prohibiting the entry of a Null in the field. Enter a value in the field.

wah
 
Have you try to put some code in the BeforeUpdate event of each of these required fields?

This code includes a simple check of the contents of the field:

>>If IsNull(Me.ThisField) then ' or any other check
>>>>Cancel=True
>>>>MsgBox "Invalid data in xxxxx",vbCritical,"Couldn't proceed record"
>>>>Me.ThisField.Undo
>>End If

Cancel=true prevent the field to be updated
Undo restore the previous content (if any) of the field
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top