How to tap error for query results?

G

Guest

I am using -

DCount("*", "AP", "File_num=" & Chr(34) & [FILE_NUM] & Chr(34) & " AND SET="
& Chr(34) & "ASKZ" & Chr(34))

How do I trap error when DCOUNT doesn't return any records?

I tried using -

Err_Form_Current:
If Err.Number = 3075 Then
Resume Next
Else
MsgBox Err.Description
Error_no = 1
End If
End Sub

Even though, Err.Number = 3075 when DCOUNT doesn't return any records,
but it still shows me MSGBOX with blank message.

I would like it not to display any messages when the query doesn't retieve
any records.

Thank you,
-Me
 
M

Marshall Barton

Me said:
I am using -

DCount("*", "AP", "File_num=" & Chr(34) & [FILE_NUM] & Chr(34) & " AND SET="
& Chr(34) & "ASKZ" & Chr(34))

How do I trap error when DCOUNT doesn't return any records?

I tried using -

Err_Form_Current:
If Err.Number = 3075 Then
Resume Next
Else
MsgBox Err.Description
Error_no = 1
End If
End Sub

Even though, Err.Number = 3075 when DCOUNT doesn't return any records,
but it still shows me MSGBOX with blank message.

I would like it not to display any messages when the query doesn't retieve
any records.


That's really strange. DCount doesn't generate an error
when there are no records to count, it just returns a value
of zero.

Maybe the error message is coming from some other action??
 
G

Guest

Hi Marsh,

You are right, looks like somehow it landed up with quotations in the
begining and
end of numeric value ie. it should have been 3956, but it had "3956" in it.
As a result the query had additional quotes and the error was different from
what I assumed it to be.

There isn't any need to check for errors for zero value returned.

Thanks much,
-Me


Marshall Barton said:
Me said:
I am using -

DCount("*", "AP", "File_num=" & Chr(34) & [FILE_NUM] & Chr(34) & " AND SET="
& Chr(34) & "ASKZ" & Chr(34))

How do I trap error when DCOUNT doesn't return any records?

I tried using -

Err_Form_Current:
If Err.Number = 3075 Then
Resume Next
Else
MsgBox Err.Description
Error_no = 1
End If
End Sub

Even though, Err.Number = 3075 when DCOUNT doesn't return any records,
but it still shows me MSGBOX with blank message.

I would like it not to display any messages when the query doesn't retieve
any records.


That's really strange. DCount doesn't generate an error
when there are no records to count, it just returns a value
of zero.

Maybe the error message is coming from some other action??
 

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