Results 1 to 6 of 6

Thread: Another ADO Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    10

    Another ADO Problem

    Ok, I am trying to make it so the ado control caption will show "Record x/y" where x = current record number and y = total number of records...

    Using the ado.recordset.recordcount option i can set the y value, but I cant seem to find an option that will display the number for the current record.

    Any help would be appreciated.

    Herb Moyer

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Check out the AbsolutePosition property of the recordset object.

    Label1.Caption = "Record " & ado.recordset.AbsolutePosition & " of " & ado.recordset.RecordCount

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    10
    Originally posted by Serge
    Check out the AbsolutePosition property of the recordset object.

    Label1.Caption = "Record " & ado.recordset.AbsolutePosition & " of " & ado.recordset.RecordCount
    yeah, i tried that, but the absoluteposition property is tricky...
    if the position is BOF it returns -2 and if EOF it returns -3...
    I tried to limit it with if statements ... such as

    if ado.recordset.absoluteposition = adPosBOF then
    ado.recordset.movefirst
    end if
    if ado.recordset.absoluteposition = adPosEOF then
    ado.recordset.movelast
    end if
    text.caption = "Record " & Form1.adoNeo.Recordset.AbsolutePosition & "/" & total

    But that still doesn't seem to do the trick...
    If it goes EOF it still shows 5/5 (doesnt do -3/5) but it also is for some reason thinking there is a 6th record, so if you hit the back previous record button, it sticks and the 4th record still says 5/5...

    Im missing the logic in the code somehow...

  4. #4
    Junior Member
    Join Date
    Apr 2001
    Location
    India
    Posts
    22
    Paste following code in the Form_load and adodc1_movecomplete event

    If Adodc1.Recordset.EOF = False And Adodc1.Recordset.BOF = False Then
    Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & "/" &
    Adodc1.Recordset.RecordCount
    End If


    Hope it helps.
    Last edited by FlyingHigh; May 26th, 2001 at 07:11 AM.
    I know I wont get much sleep tonight but that does'nt stop me from going to bed.

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Before opening recordset, make sure CursorLocation property set to adUseClient. The default one is adUseServer which will make AbsolutePostion always return -1.
    So, as I said, before opening recordset, set the property accordingly:
    Code:
    ado.Recordset.CursorLocation = adUseClient
    ado.Recordset.CursorType = adOpenStatic
    ado.Recordset.Open

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    10
    Originally posted by FlyingHigh
    Paste following code in the Form_load and adodc1_movecomplete event

    If Adodc1.Recordset.EOF = False And Adodc1.Recordset.BOF = False Then
    Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & "/" &
    Adodc1.Recordset.RecordCount
    End If


    Hope it helps.
    Thank you very much, it works perfectly. Heh, I knew there had to be some if statements to prevent it from going BOF or EOF, but I just couldn't figure out the logic in it

    Thank you again!

    Herb Moyer

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