Check record count in a subform

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.
 
M

Marshall Barton

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
 

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