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
 

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

Similar Threads

Access Main form/Subform Navigation 0
Multiple subforms 0
Subform reference 20
recordset clone 1
subform total to mainform 2
subform total behaving strangely 2
Problem refreshing subform 2
showing a subform based on the main form 5

Back
Top