Results 1 to 3 of 3

Thread: I cant get AbsolutePosition to work!!

  1. #1

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    I cant get AbsolutePosition to work!!

    Im using a access MDB file.

    When im trying to show current record like

    VB Code:
    1. lbl.caption = "Record " & db.OpenRecordset("Info").AbsolutePosition & " of " & _
    2. db.OpenRecordset("Info").RecordCount

    it wont work. the absolute position

    error:
    operation not supported for this type of object.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: I cant get AbsolutePosition to work!!

    Let's see.... how can I put this? Simply put, you are doing it wrong. That's why it doesn't work.

    .OpenRecordset does just that, it opens a recordset. You need to assign it to a Recordset variable _FIRST_ before you try to access the properties like that.

    VB Code:
    1. set myRecordset = db.OpenRecordset("Info")
    2. lbl.caption = "Record " & myRecordset.AbsolutePosition & " of " & _
    3. myRecordset.RecordCount
    Once you have opened the recordset, then and only then will the RecordCount and AbsolutePosition work.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: I cant get AbsolutePosition to work!!

    VB Code:
    1. Set rsInfo = .OpenRecordset("Info", dbOpenDynaset)
    2. Form1.Label1.Caption = rsInfo.AbsolutePosition + 1 & " / " & rsInfo.RecordCount
    Will only work when I use dbOpenDynaset. I have no idea what it does, but I looked through som sources in pscode and people are using it.

    What does it do? Because it wont work without it.


    And another question.

    VB Code:
    1. Private Sub Cmd_Delete_Click()
    2.     With rsInfo
    3.         If rsInfo.RecordCount > 0 Then
    4.             .Delete
    5.             Form1.Label1.Caption = .AbsolutePosition + 1 & " / " & .RecordCount
    6.  
    7.                 Else
    8.                 MsgBox "No More Records"
    9.         End If
    10.     End With
    11. End Sub
    When deleting it gets wacked. It looks like 0 / 4 instead of 3/4 if I've deleted record previous 4 / 5.

    Also when I load the projekt the recordcount is 1, I have to put getrows or
    movenext moveprevious to get it to work. movelast works too, but not move first. then it looks like 1/1

    Any ideas on this?

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