|
-
May 25th, 2001, 11:59 PM
#1
Thread Starter
New Member
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
-
May 26th, 2001, 12:47 AM
#2
Check out the AbsolutePosition property of the recordset object.
Label1.Caption = "Record " & ado.recordset.AbsolutePosition & " of " & ado.recordset.RecordCount
-
May 26th, 2001, 12:55 AM
#3
Thread Starter
New Member
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...
-
May 26th, 2001, 05:23 AM
#4
Junior Member
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.
-
May 26th, 2001, 02:34 PM
#5
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
-
May 27th, 2001, 10:26 AM
#6
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|