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. Anonymous
    2011-02-17T20:14:19+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.

    Was this answer helpful?

    0 comments No comments