Check if any records exist in subform (1 Viewer)

virencm

Registered User.
Local time
Today, 22:55
Joined
Nov 13, 2009
Messages
61
Hi

How do i check if any records exist in a subform... if there are records then tick checkbox , else untick.

The code I 'm using doesnt seem to work

Code:
If IsNull(Me.Unissued_material_list_subform) Then
Me.Check92 = 0
Else
Me.Check92 = -1
End If
thanks.
 

PeterF

Registered User.
Local time
Today, 12:55
Joined
Jun 6, 2006
Messages
295
Your code fails because you are testing a subform, it's a control this means not null.

You need to test if the recordsource of the form contains records like:
Code:
 If Me.Unissued_material_list_subform.recordsource.Form.Recordset.RecordCount <> 0 then
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 11:55
Joined
Jan 22, 2010
Messages
26,374
Fyi: To get the correct name of the subform control, click on the subform ONCE and look in the Property Sheet. If you click on it a second time, it will take you to the form embedded in the subform control.

What you want is the name of the subform control.
 

virencm

Registered User.
Local time
Today, 22:55
Joined
Nov 13, 2009
Messages
61
Thanks Peter, Your solution worked perfectly
 

mcfg

New member
Local time
Today, 06:55
Joined
Dec 13, 2013
Messages
2
I had the same question & came across this post. I found the below to work as well:
Code:
Me.Recordset.EOF
I tried that method as I was under impression .RecordCount property might not work if using a certain type of locktype (forward-only)
 

Users who are viewing this thread

Top Bottom