re: recordcount syntax for nested subform

alicejwz

Registered User.
Local time
Today, 08:28
Joined
Jul 9, 2003
Messages
91
re: recordcount syntax for nested subform

Hi,

I'm trying to find out if there is a record in the nested subform from the subform. MS VB Error: Object variable or with block variable not set.

My code:
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click
dim rec_cnt As Integer
Dim rst As New ADODB.Recordset
Dim rstclone As New ADODB.Recordset

'''Error occurred on the next line
rec_cnt = Me!RMR_desc_defects_subform.Form.Recordset.RecordCount

If rec_cnt > 0 Then
Set rst = Me.Recordset
Set rstclone = Me.RecordsetClone
rst.MoveNext
rstclone.MoveNext

end if

I also tried
rec_cnt = Me!RMR_desc_defects_subform.Form.RecordsetClone.RecordCount
If rec_cnt > 0 Then
:
end if
then I get this
Error mess: You entered an expression that has an invalid reference to the recordsetclone property.

I appreciate your help .
 
Alice,

A place to start, perhaps...

Code:
 Dim rs As Object
 Set rs = Me.Recordset.Clone
    
 MsgBox rs.RecordCount

Regards,
Tim
 
The reference looks correct, see my answer in your other thread regarding subform referencing.

I'd also try using the recordsetclone to fetch the count, not the recordset.

pono1 has a point - form recordsets in mdb's, unless spesificly set to ADO, are DAO. For ADP's they are ADO. The recordsetclone property, I think is not available in 2000, but I think it should work in 2002+, so using late binding and the .clone method of the recordset might do the trick.
 

Users who are viewing this thread

Back
Top Bottom