Private Sub CmdRecordcount_Click()
'in the following example i have selected all the fields in the table
'this will help in referencing all the fields in the table
rs.Open "select * from tbl_studentdetails where studentid='" & stuid & "'", cn, adOpenStatic, adLockOptimistic, adCmdText
noofrecords = rs.RecordCount
Print "Number of records = " & noofrecords 'this returns number of records
Print rs.Fields("studentid") & vbTab & rs.Fields("FirstName") & vbTab & rs.Fields("LastName") 'this returns fields in the record set
Just a note of warning, doing a select * and then using variable = rs.recordcount may return undesirable results. To be more specific, it may return a -1, which means it returned records (not zero (0)), but the amount of records are larger than the page size. So to fix this possible result, I suggest that you do...