Minggu, 04 Mei 2014

Re: [MS_AccessPros] Error Handling

 

Phucon-


It's better to trap it in the control's Before Update event.  You can set Cancel = True to kill the "edit" and then Me.Undo to "un-dirty" the form.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On May 5, 2014, at 1:16 AM, <saigonf7q5@yahoo.com> <saigonf7q5@yahoo.com> wrote:

When users selecting an option from a combo box, instead of clicking on the dropdown arrow to select it, some users like to use key board to type in what they want. Sometimes they delete what's been entered and close the form or exit the application. That triggers the  "data type mismatch" or "Invalid use of Null" error. I tried 2 different ways to handle the errors.

 

1, is to handle it from the beginning of the combo box's AfterUpdate Event procedure:

 

If IsNull(cboFind) or cboFind = "" Then

                Exit Sub

End If

 

2, I do it in the ErrorHandler section:

 

If Err.Number = 94 Then

                Exit Sub

Else

                MsgBox Err.Number & Err.Description

End If

 

Both ways handled the errors OK, but which one is the better or an appropriate way to do?


Phucon



__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Did you check out automatic photo albums in Yahoo Groups?
When you send mail to your Yahoo Group with photos attached, a photo album with attached photos is automatically created. When your group members reply to the email with photo attachments, those photos are added to the 'photomatic' albums automatically!

.

__,_._,___

Tidak ada komentar:

Posting Komentar