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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to suppress vba errors?

Status
Not open for further replies.

jsilveira

MIS
Feb 7, 2005
46
0
0
CA
Hi,

I currently have a form with combo boxes. These combo boxes are required to be filled. However, if left empty and moved to the next, Access pops up with the 3315 zero field error message. Does anyone know how to suppress the generic microsoft error and replace it with a user friendly message?

thanks,
jsilveira
 
You can put a validation rule on the Controls and/or fields themselves, and you can write your own validation function that you run in the BeforeUpdate event of the form.

If your validation test does not pass, cancel the update and give the user a friendly swat to the head message. ;-)

HTH
 
Hi
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
'Goes in a form module
'3314    The Field '|' cannot contain a Null value
'        because the Required property for this field
'        is set to True.  Enter a value in this field.
'3315    Field '|' cannot be a zero-length string.
Const NO_NULLS = 3314
Const NO_ZLS = 3315
    If DataErr = NO_NULLS Or NO_ZLS Then
       MsgBox "Tut, tut!"
       Response = acDataErrContinue
    End If
End Sub
 
Hi,

I have a form that contains a subform, what i want to do is once the user has selected the options, he will then go to the subform, but when the user clicks on the subform it will prompt him to make sure he has not left anythign blank. I have tried putting it on the subform or on the main form (on error) but microsoft errors keep coming first then my errors are shown. Any ideas?

Thanks,
jsilveira
 
have you got error capture in the events which trigger the error?

--------------------
Procrastinate Now!
 
Hi,

I'm not too sure as to where that would be. The form is a made of 2 parts.

1st part: 5 combo boxes

2nd part: subform with 2 (A & B) combo boxes. If the user clicks A, then I would like it to valide the 5 boxes and whether it has left anything blank, if so display my error message. Based on the combo box properties, there is no "on error".

I have tried putting it on both the on error for both forms, but without any luck.

Thanks for the assistance!
jsilveira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top