Check record count in a subform

  • Thread starter Thread starter Nicole
  • Start date Start date
N

Nicole

I there,
I have a subform on my main form. Here is what I want to
do.
If the subform has no records returned then I want to hide
the subform and show a text message box instead.

I've tried
Private Sub Form_Current()
If frmStudent_DegreeProgram_Accepted!Degree = " " Then
frmStudent_DegreeProgram.Visible = False
End If
End Sub

but I get the error message:
Runtime error 2427
You entered an expression that has no value.
 
Nicole said:
I there,
I have a subform on my main form. Here is what I want to
do.
If the subform has no records returned then I want to hide
the subform and show a text message box instead.

I've tried
Private Sub Form_Current()
If frmStudent_DegreeProgram_Accepted!Degree = " " Then
frmStudent_DegreeProgram.Visible = False
End If
End Sub

but I get the error message:
Runtime error 2427
You entered an expression that has no value.

Try this:

Private Sub Form_Current()
With Me. frmStudent_DegreeProgram_Accepted
.Visible = .Form.RecordsetClone.RecordCount > 0
End With
End Sub
 
Back
Top