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

Ignoring some warnings, and processing others

Status
Not open for further replies.

BigTeeJay

Technical User
Jun 13, 2001
106
US
Hey,
Any one know of a way to do selectively process or ignore
warnings? (if I set showwarnings = false, I dont get any,
if I set it to true, i get all of them).

I want to be able to handle & inform a user of a Primary
Key constraint error (when inserting) but essentially ignore
all other warnings.

I have been digging around on the net (and tek-tips) and havent really been able to find an answer (yet).

Regards,
Tj
 
Not quite sure what you are asking? You should be handling form errors on the form level and based on the error you can choose to show the error or hide it at that point. Life's a journey enjoy the ride...

jazzz
 
Right, you can handle errors... but you cant handle
warnings right?

For instance, if you wanted to be able to handle an
addition of a record, but not display any warning
about deleting a record? If you set warnings off
you wont see either (and the err object doesnt give
anything, since they are only warnings).

I realize I can program something to handle each
issue, but was wondering if any one knows of
something similiar (at least in functionality) to
the err object/collection for warnings?
 
Yes you can suppress the default error message. For example to suppress the Access Error message that appears when you delete a record you can do something like this.

Bear in mind I am using custom default error handlers so please place your own in there so you don't generate an error.

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)

On Error GoTo DefaultHandler
'* don't display the standard Access error message.

Response = acDataErrContinue

SubExit:
Exit Sub

DefaultHandler:
'* If we run into an error display our form and create an
'* errorlog.txt file. If no error's are detected exit the
'* program.

Select Case Err.Number
'* Handle errors here.

Case Else
Call ShowError(Me.Name, "Form_BeforeDelConfirm", Err.Number, _
Err.Description)
End Select
Resume SubExit


End Sub


Private Sub Form_Delete(Cancel As Integer)

On Error GoTo DefaultHandler

Dim strMsg, Style, Title, UserResponse
Dim Response As Integer

'*Note: This procedure is used to confirm a deletion. Ask the user
'* if they are sure that is what they want to do?

strMsg = "Delete record ..." & vbCrLf & vbCrLf _
& Me("txtid") & "?" & vbCrLf & vbCrLf _
& "This process cannot be undone." & vbCrLf _
& "Do you want to continue?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "WARNING Just Some Stuff!" ' Define title.

'* Wait here till the user decides what they want to do.
DoCmd.Beep
UserResponse = MsgBox(strMsg, Style, Title)

If UserResponse = vbYes Then ' User chose Yes.

'* The user selected yes so complete the delete
Else

'* The user chose to cancel the delete so restore
'* the record.
Cancel = True
End If

SubExit:
Exit Sub

DefaultHandler:
'* If we run into an error display our form and create an
'* errorlog.txt file. If no error's are detected exit the
'* program.

Select Case Err.Number
'* Handle errors here.

Case Else
Call ShowError(Me.Name, "Form_Delete", Err.Number, _
Err.Description)
End Select
Resume SubExit


End Sub
Life's a journey enjoy the ride...

jazzz
 
One final thought here. If you set the warnings to false in your event ALWAYS in your exit routine for the event set the warnings back to true. So you will always receive the warnings. Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top