subform visible only sometimes

J

Jim

I have a form with a subform. i would like the subform to be visible only when there is data on the subform. Most of the records do not have a related record on the subform. When i go from one record to the next record, I get an error message asking for the item in the child field for the subform. Most of the time there is no corresponding child data. Is there a way I can get the subform to only show up (and no error message looking for the child field) when there is corresponding data

Thanks to all who respond

Jim
 
R

Reggie

As seen on the Access Web (http://www.mvps.org/access/forms/frm0029.htm)

Place this on the OnCurrent event of the main form.
Private Sub Form_Current()
With Me![SubformName].Form
.Visible = (.RecordsetClone.RecordCount > 0)
End With
End Sub


--
Reggie

www.smittysinet.com
----------
Jim said:
I have a form with a subform. i would like the subform to be visible only
when there is data on the subform. Most of the records do not have a
related record on the subform. When i go from one record to the next
record, I get an error message asking for the item in the child field for
the subform. Most of the time there is no corresponding child data. Is
there a way I can get the subform to only show up (and no error message
looking for the child field) when there is corresponding data?
 

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