wrong display of absolute position and recordcount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nkechifesie
    New Member
    • Nov 2006
    • 62

    #1

    wrong display of absolute position and recordcount

    I want my form to display the absolute position and the recordcount of the records in the database but it keeps shoing me -1 for both . Why?
    this is the code

    Code:
    Private Sub MnuOVehType_Click()
    Load FrmTypeEntry
    For i = 1 To 4
        FrmTypeEntry.cmdControl(i).Enabled = True
    Next i
    For j = 0 To 3
        FrmTypeEntry.cmdNavigate(j).Enabled = True
    Next j
    FrmTypeEntry.TxtType.Locked = True
    FrmTypeEntry.TxtType.Text = RsVehType("txtVEHTYPE")
    [B]FrmTypeEntry.Label1.Caption = "VEHICLE TYPE " & RsVehType.AbsolutePosition & "of" & RsVehType.RecordCount[/B]
    End Sub
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Just a couple of thoughts...
    • RecordCount is often simply 0 (no match) or 1 (one or more matches) until you move to the end of the recordset to force the Jet engine to count them. You might try doing MoveLast...Move First somewhere before accessing the RecordCount, just to see what happens.
    • I'm not familiar with AbsolutePositio n, but my guess would be that it's the "absolute" position within that recordset, not within the table. I don't think Access keeps any unique record position or record number - you have to do that yourself by using an autonumber field.

    Well, hope this doesn't lead you too far astray. :)

    Comment

    • Andrew Thackray
      New Member
      • Oct 2006
      • 76

      #3
      You can only get the record count and absolute position if you open the recordset using adopenkeyset or adopendynamic as the cursor type. The other cursor types don't populate the recordset until requested so the recordcount & absolute position are not known and always appear as -1

      Comment

      • nkechifesie
        New Member
        • Nov 2006
        • 62

        #4
        RESOLVED

        Thank you all for your suggestion. I set the cursor location to aduseclient and it works.

        Comment

        Working...