View Full Version : trapping errors - is there access equivalent of iserror in excel


grapevine
02-22-2009, 02:31 AM
I have the field shown below in a query which is now working properly and correctly putting either Overdue or Not Overdue in a new field. I am then searching on this field to obtain any overdue records. This is all fine.

Reviewdate1: IIf(DateAdd("d",(([courseplannedenddate]-[coursestartdate])/5),[coursestartdate])<=Date(),"overdue","notoverdue")

But, if either the courseplannedenddate or the coursestartdate are empty then the whole query fails (data mismatch). How can I trap the error in Access. If this was a problem in Excel I would use iserror but I have no idea of the syntax to use in Access.

Can you do a nested if in Access?
How can I trap the error?
Or is there a better way of approaching this? Am I thinking too much Excel and not enough Access?
Any assistance greatly appreciated
Marion

thingssocomplex
02-22-2009, 04:10 AM
Could you not use 'Is Null' Or 'Is Not Null' in your query on the date fields!

grapevine
02-22-2009, 06:05 AM
Thank you so much - such a easy solution! I have tested it out and everything works a treat.

Much obliged for your time.
Marion

thingssocomplex
02-22-2009, 06:11 AM
Hi Marion,

I am still very much a novice myself, but to answer your question you can nest IIF statements just by adding multiple IIF statements and it would check the condition of True Or False on each.

grapevine
02-22-2009, 08:37 AM
Thank you for your comment about nested ifs. I had experimented but I could not get the iserror part of the if problem sorted so your first solution was so clean and simple that I used that instead.

Many thanks for your help