subform visible only sometimes

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

Guest

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
 
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?
 
Back
Top