J
Jeff
Hi All,
I have some code to check how many records a subform (in datasheet view)
has. The subform has a query as a source and master-child fields to link
to the mainform.
On the mainform I have a textbox that receives the number of records
from the code (On current event of subform).
The code works ok except when there are no records. The textbox shows
the same number as for the last mainform record.
Any ideas greatly appreciated,
Jeff C.
Code:
Set rsd = Me.Form.RecordsetClone
With rsd
.MoveLast
Rc = .RecordCount
If Rc > 0 Then
Me.Parent.Form.RecNo = rsd.RecordCount
'MsgBox Rc
Else
Me.Parent.Form.RecNo = "NR"
MsgBox Me.RecordsetClone.RecordCount
End If
End With
rsd.Close
Set rsd = Nothing
I have some code to check how many records a subform (in datasheet view)
has. The subform has a query as a source and master-child fields to link
to the mainform.
On the mainform I have a textbox that receives the number of records
from the code (On current event of subform).
The code works ok except when there are no records. The textbox shows
the same number as for the last mainform record.
Any ideas greatly appreciated,
Jeff C.
Code:
Set rsd = Me.Form.RecordsetClone
With rsd
.MoveLast
Rc = .RecordCount
If Rc > 0 Then
Me.Parent.Form.RecNo = rsd.RecordCount
'MsgBox Rc
Else
Me.Parent.Form.RecNo = "NR"
MsgBox Me.RecordsetClone.RecordCount
End If
End With
rsd.Close
Set rsd = Nothing