Iserror Syntax

M

MIG

I have searched through this group and found people repeatedly asking
how to get Iserror to work, and not a single reply has ever addressed
the question. Responders go on about what the error was, which is
irrelevant.

I am getting a similar problem which is that if there's ANY error I
want to return SOMETHING ELSE.

This does not seem to be possible. How can one use the Iserror
function to return SOMETHING ELSE when there's an error instead of
just #Error.

There's no point in error-trapping with a function that still just
returns #Error.

I am sure that this must be a simple question of syntax, but I am at a
loss.
 
J

John W. Vinson

I have searched through this group and found people repeatedly asking
how to get Iserror to work, and not a single reply has ever addressed
the question. Responders go on about what the error was, which is
irrelevant.

I am getting a similar problem which is that if there's ANY error I
want to return SOMETHING ELSE.

This does not seem to be possible. How can one use the Iserror
function to return SOMETHING ELSE when there's an error instead of
just #Error.

There's no point in error-trapping with a function that still just
returns #Error.

I am sure that this must be a simple question of syntax, but I am at a
loss.

Here's some code I've used in a VBA routine:

Public Function FindCorruptRecord(Tablename As String, Fieldname As String, PK
As String) As Long
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset(Tablename)
Dim iRec As Long

FindCorruptRecord = 0
With rs
Do While Not .EOF
If IsError(rs.Fields(Fieldname)) Then
Debug.Print "*******Error in " & Tablename & "." & Fieldname & " " &
PK
Stop
End If
If Not IsNull(rs.Fields(Fieldname)) Then
FindCorruptRecord = FindCorruptRecord + 1
End If
.MoveNext
Loop
End With

rs.Close
Set rs = Nothing

End Function

You can also use this in the control source of a textbox:

=IIf(IsError(Me.fieldname), "No data available", Me.Fieldname)
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top