if recordset returns Null ?

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I have the following:

Forms!frmInventoryUsage.RecordSource = "TemporaryQuery"
Set rstOriginalReport = Forms!frmInventoryUsage.Recordset

The problem is when recordset returns nothing something
wrong is happening with the form. It would be better to
check whether it's nothing befor
Set rstOriginalReport = Forms!frmInventoryUsage.Recordset
to skip it in this case and go out from the function.

I would appreciate if any body could advise how to do that.

Thanks advance,

Alex
 
Alex said:
I have the following:

Forms!frmInventoryUsage.RecordSource = "TemporaryQuery"
Set rstOriginalReport = Forms!frmInventoryUsage.Recordset

The problem is when recordset returns nothing something
wrong is happening with the form. It would be better to
check whether it's nothing befor
Set rstOriginalReport = Forms!frmInventoryUsage.Recordset
to skip it in this case and go out from the function.


You could use:
If DCount("*", "TemporaryQuery") = 0 Then
Exit Function
End If
before setting the record source.

Or:
With Forms!frmInventoryUsage.Form
If .RecordsetClone.RecordCount = 0 Then
Exit Function
End If
End With
after setting the record source.
 
Back
Top