Function to look for errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following sub that calls a function, which works great if errors
are found, but if none are found, I get an error: "You cancelled the previous
operation." What am I doing wrong, I thought 'DCount' would return NULL if
none are found...?

Private Sub Check_Errors()

Dim varErrs as Variant
varErrs = ResolveErrors
If varErrs Is Null Then Exit Sub

{other code here}

End Sub

Private Function ResolveErrors() As Variant

ResolveErrors = DCount("*", [pcstrTableMerge], "[RPT_CODE] IS NULL")

End Function
 
Domain Aggregate functions will return a zero, not null, if no record
matches the criteria in the specified domain... Therefore, change:
If varErrs Is Null Then Exit Sub

to

If varErrs = 0 Then Exit Sub

and the problem should be solved.

HTH,
Nikos
 

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

Back
Top