Results 1 to 3 of 3

Thread: ADO Data Control - Record Number

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    ADO Data Control - Record Number

    I am using the ADO Data Control but am not sure how to write a procedure to show the status of the current record in a recordset. I have previously done this with the standard Data Control using the Reposition event:

    Private Sub Data1_Reposition()

    Screen.MousePointer = vbDefault
    On Error Resume Next

    lblStatus.Caption = "Record " & Data1.Recordset.AbsolutePosition + 1 & " of " & Rcount

    End Sub

    How can I do this with the ADO Control ?

  2. #2
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    VB Code:
    1. Private Sub SetRecordNumber()
    2.  
    3.     Dim intRecordCount As Integer
    4.     Dim intCurrentRecord As Integer
    5.  
    6.     With ADODC1.Recordset
    7.         intRecordCount = .RecordCount
    8.         intCurrentRecord = .AbsolutePosition
    9.         lblRecordNumber.Caption = "Record " & intCurrentRecord & _
    10.                                      " of " & intRecordCount
    11.  
    12.      End With
    13.                                      
    14. End Sub
    15.  
    16. Private sub Command1_Click()
    17.  
    18.    SetRecordNumber
    19. End Sub
    Last edited by vbvbvbvb; Jan 10th, 2002 at 09:01 AM.

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking uh?

    Sorry, that won't work. Your varibles are local.

    U can use:

    VB Code:
    1. Private Function GetRecordNumber() As String
    2.     With ADODC1.Recordset
    3.         GetRecordNumber = "Record: " & .AbsolutePosition & " of " & .RecordCount
    4.     End With
    5. End Sub
    6.  
    7. Private Sub Command1_Click()
    8.     MsgBox GetRecordNumber, vbInformation, "Current Record"
    9. End Sub

    Does this work?

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