Share via

Access Ignore Errors

Anonymous
2011-02-17T14:33:59+00:00

I know that in Excel, there is a VBA method, expression.IfError(Arg1, Arg2), that will tell the program to return a specified value if the result of the first argument is an error.  Does Access have a similar function or method?  And if so, what is the syntax?

Much appreciated.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-02-17T20:48:15+00:00

I have a string of code in the Control Source Property of textbox: txtHXRShellWall:

=DLookUp("[Shell Wall]","[tblSSPipeSizes]","[Pipe OD]=" & [cmbHXRShellOD] & " And [tblSSPipeSizes]![SS Schedule]='10S'")

Everything works fine if the user selects a choice from the dropdown list of combobox: cmbHXRShellOD.  But I also want to allow the user to input a custom number in this combobox.  If I do that, the Dlookup function returns a #Error in txtHXRShellWall because it cannot find the value in the Pipe OD field of table: tblSSPipeSizes.  I would like the code to return a zero value ("") if the Dlookup returns an error.

IsError() just returns a boolean value if there is an error.

Just change your control source to this:

=Nz(DLookUp("[Shell Wall]","[tblSSPipeSizes]","[Pipe OD]=" & [cmbHXRShellOD] & " And [tblSSPipeSizes]![SS Schedule]='10S'"),"")


Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)

Was this answer helpful?

0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Anonymous
    2011-02-17T16:28:45+00:00

    There is a function and it is

    IsError([Somethinghere])

    But it doesn't work for everything that you might think it would. 


    Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-02-17T15:07:47+00:00

    yes you will want to do this in your error handling part of VBA:

    If Err.number = ## Or Err.number = ## Then

            'do something

    End If

    you can have it do anything you can imagine in vba.  i have some errors ignored, some have message boxes to the user, some create an editable email to myself so the user can explain and then i can see what is going on, or just auto send an email.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-02-17T14:52:42+00:00

    Hi

    Not that I know of.

    Can you tell us more of what you are trying to do.  Someone may be able to give you an alternative.


    Hope this helps Bob Fitz BizSoftware If this answer solves your problem, please check, Mark as Answered. If this answer helps, please click the Vote as Helpful button.

    Was this answer helpful?

    0 comments No comments