Results 1 to 8 of 8

Thread: [RESOLVED] Record Count

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2008
    Location
    Maidstone Kent UK
    Posts
    51

    Resolved [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

  2. #2
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2008
    Location
    Maidstone Kent UK
    Posts
    51

    Re: Record Count

    Nitesh

    It works though only when I click on the label itself.

    prme

  4. #4
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2008
    Location
    Maidstone Kent UK
    Posts
    51

    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

  6. #6
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2008
    Location
    Maidstone Kent UK
    Posts
    51

    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

  8. #8
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Record Count

    All you need to do is call the sub where you populated the Recordset in under the mnuUpdate_Click() Event.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width