Refering to Subforms through Code

  • Thread starter Thread starter David W
  • Start date Start date
D

David W

Is there a way to deal with no records in a subform?

I have a subform linked to a form, sometimes there are no records in the
subform(its because there are no records associated with the main form for
that record).
I have some code in the main form that checks the totals in the subform
against the main form and I run into errors when there are no records in the
subform, how do you refer to a record that does not exist?
 
David said:
Is there a way to deal with no records in a subform?

I have a subform linked to a form, sometimes there are no records in the
subform(its because there are no records associated with the main form for
that record).
I have some code in the main form that checks the totals in the subform
against the main form and I run into errors when there are no records in the
subform, how do you refer to a record that does not exist?


You can't refer to a nonexisting record. What you can do is
check if the subform has no records and do something else.

If Me.subform.Form.RecordCount > 0 Then
'there are records
Else
'No records
End If
 
Back
Top