-
[RESOLVED] Record Count
Using the Access wizard, I have created a database and want to display the number of records currently in the database, or better still allow the current record / total records in database to be shown.
The ADODC shows the number of records in the database but, I have turned the visable property to false (ADODC) and created two buttons in place of. They are Previous and Next.
I want to beable to display, current and total records using a label on the form.
Thanks
-
Re: Record Count
I ain't 100% sure because it's been years since i've worked with the adodc control. But this should work for you:
Code:
label1.caption = Adodc1.Recordset.RecordCount
-
Re: Record Count
Nitesh
It works though only when I click on the label itself.
prme
-
Re: Record Count
did you place that line of code in the same sub where you are populating the recordset. I assume you have somewhere in your code :
adodc1.recordsource = ......
put the line of code I gave you after that. Im assuming you have checks to see if the EOF is true. If you post your code I could help you more.
-
Re: Record Count
Nitesh
I have used the wizard to start with which produces this code for the ADODB and would like to use the label instead. Your example code as:
Label3.Caption = datPrimaryRS.Recordset.RecordCount
was placed in label3.
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This will display the current record position for this recordset
datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
I hope that is what you can work with.
prme
-
Re: Record Count
No, placing that code under the label is wrong. Post me the code where you populate the recordset. Post you whole code if possible
-
Re: Record Count
Nitesh
Realising my error, after you pointed it out I pasted it into the form code and it works. but will not refresh until you exit and then return to the program.
I have however an update button with the:
Private Sub mnuUpdate_Click()
On Error GoTo UpdateErr
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
which does not update the record count.
would you beable to throw some light on that for me.
much appricated
prme
-
Re: Record Count
All you need to do is call the sub where you populated the Recordset in under the mnuUpdate_Click() Event.