dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Vs: Database question : movenext and moveprevious giving error

  1. #1
    Erik Guest

    Vs: Database question : movenext and moveprevious giving error

    Thanks Dean,

    I think I explained my problem a little vague. If my user clicks on the
    Previous button, I need to check if I'm already at the beginning of the
    database. If so, stay at first record. If not, go to previous record.

    My problem lies in the fact that although the user IS on the first record,
    the app tries to perform the rs.MovePrevious line in the code thus trying to
    go to a record BEFORE the first record giving me the No More Records error.

    Am I somehow checking the .BOF and .EOF in a wrong way....

    Case 1 'first
    rs.MoveFirst
    FillList
    Case 2 'previous
    If rs.BOF = True Then << SHOULD BE TRUE WHEN USER ON
    FIRST RECORD
    rs.MoveFirst << NO .MOVEPREVIOUS ALLOWED
    Exit Sub << DOESN'T EXIT
    Else
    rs.MovePrevious << STILL EXECUTES THIS LINE
    FillList
    End If

    Erik

    : Try removing those 2 lines. As its already at the beginning/end of the
    recordset, there is no need to explicitly say to go to them.
    :
    : --
    : Dean Earley (dean.earley@icode.co.uk)
    : Assistant Developer
    :
    : iCode Systems
    :
    :



  2. #2
    Arthur Wood Guest

    Re: Vs: Database question : movenext and moveprevious giving error


    Erik,
    Actually,

    If rs.BOF = True Then << SHOULD BE TRUE WHEN USER ON
    FIRST RECORD
    is Not quite correct. rs.BOF is ONLY true when the recordset is positioned
    BEFORE the first record ( meaning that you attempted to move Back, from the
    first record). Thus, what you want to is to check for BOF immediately AFTER
    you attempt the rs.MovePrevious:

    rs.MovePrevious
    if rs.BOF then
    rs.MoveFirst
    End If
    FillList

    simialrly for the MoveNext:

    rs.MoveNext
    if rs.EOF then
    rs.MoveLast
    end if
    FillList


    Arthur Wood


    "Erik" <jan.sagfors@skv.fi> wrote:
    >Thanks Dean,
    >
    >I think I explained my problem a little vague. If my user clicks on the
    >Previous button, I need to check if I'm already at the beginning of the
    >database. If so, stay at first record. If not, go to previous record.
    >
    >My problem lies in the fact that although the user IS on the first record,
    >the app tries to perform the rs.MovePrevious line in the code thus trying

    to
    >go to a record BEFORE the first record giving me the No More Records error.
    >
    >Am I somehow checking the .BOF and .EOF in a wrong way....
    >
    >Case 1 'first
    > rs.MoveFirst
    > FillList
    > Case 2 'previous
    > If rs.BOF = True Then << SHOULD BE TRUE WHEN USER

    ON
    >FIRST RECORD
    > rs.MoveFirst << NO .MOVEPREVIOUS ALLOWED
    > Exit Sub << DOESN'T EXIT
    > Else
    > rs.MovePrevious << STILL EXECUTES THIS LINE
    > FillList
    > End If
    >
    >Erik
    >
    >: Try removing those 2 lines. As its already at the beginning/end of the
    >recordset, there is no need to explicitly say to go to them.
    >:
    >: --
    >: Dean Earley (dean.earley@icode.co.uk)
    >: Assistant Developer
    >:
    >: iCode Systems
    >:
    >:
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center