Text no data if subform is empty?

  • Thread starter Thread starter Harmannus
  • Start date Start date
H

Harmannus

Hallo,

Is there a way to show the text "No data" if a subform has no records/is
empty? I have a subform on my switchboard with one field in it. That should
be replaces with the text "No data" if there are no records. Either replace
the normal field with a text no data or make the subform invinsible if no
data and make a label no data visible.

Can this be done?

Regards,
Harmannus


Tried the below in the on open event of the subform but no effect ;-)

IIf not isnull(DCount("*", "qselSubform") then
'show data
else
me.subformfield="No data"
end if
 
In the parent form's Current event, check the RecordCount of the subform and
hide the subform control if there are no records. You could make a label
visible at the same time, if you wanted, that states No Records.

If Me.NameOfSubformControl.Form.Recordset.RecordCount = 0 Then
Me.NameOfSubformControl.Visible = False
Else
Me.NameOfSubformControl.Visible = True
End If

The NameOfSubformControl is the name of the control that holds the subform
on the main form, not the name of the subform itself. To get this name, open
the main form in design mode, open the Properties sheet, and click on the
subform ONE time. The properties sheet should show the name of the subform
control. If you click more than once, you'll be in the subform itself and
the properties sheet will show the name of the subform, not the name of the
control holding it.
 
Back
Top