DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 14 of 14

Thread: data1.recordset.movenext & moveprevious

  1. #1
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230

    data1.recordset.movenext & moveprevious

    guy,

    I am using a touchscreen with 2 images (up and down arrows) to move throw a data1 database.

    My problem is when I get the begin or the end of the file it still trys to move the recordset and I get a error.

    How can I disable image1 (up arrown) when the database reaches or is at the first record also when it reaces the last record (for the down image)

    Thanks for any help I hope i explain this correct.

    Drew

  2. #2
    Join Date
    May 2006
    Posts
    40
    It has been a little while since I've used VB6 (actually a long while) but here goes nothing.

    The last record can be checked using the EOF property and then the image can be disabled if it is (e.g. if RS.EOF = true then imagedown.enabled = false)

    As for the first record I'm unsure whethere this is actually valid syntaxing or if I made this property up but I'm sure it had BOF which can be used the same as EOF (e.g. if RS.BOF = true then imageup.enabled = false)

    Hope this helps

  3. #3
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    Well that is the code I am using at the moment but it trys to go pass the last and first records in the database.

    any thoughts guys & gals?

    Drew

  4. #4
    Join Date
    May 2006
    Posts
    40
    Ok racking my brains and it's extremely hard as .net extremely different.

    Is there not a count and selectedcell (or selectedindex) property? I seem to recall one in which case, check the selected doesn't equal the count.

    Hope this is helpful and correct?

  5. #5
    Join Date
    Dec 2003
    Posts
    2,750
    Could you post your code? I'm assuming that you are checking for BOF and EOF after MovePrevious/Next respectively?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  6. #6
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    well the code is
    ' image 1 ( backward arrow)
    if data1.recordset.BOF = TRUE THEN
    image1.enabled = false
    else
    data1.recordset.moveprevious
    end if

    ' image 2 (forward arrow)
    if data1.recordset.EOF = TRUE THEN
    image2.enabled = false
    else
    data1.recordset.movenext
    end if

    but it keeps trying to go beond the eof and bof not sure why

  7. #7
    Join Date
    May 2006
    Posts
    40
    Could you also please post your code that connects / opens the database. As this is most likely the cause.
    J JJ

  8. #8
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    Sure that is

    Data1.databaseName = App.path & "\products.mdb"
    Data1.Refresh

    The database is LOCAL ONLY no other conection is active on it

  9. #9
    Join Date
    Dec 2003
    Posts
    2,750
    When does the code you posted execute?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  10. #10
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    When the form activates

    Sorry I fogot to mention that

  11. #11
    Join Date
    Dec 2003
    Posts
    2,750
    Are you sure you want to use the Activate event? Shouldn't the code execute after clicking (pressing) on the Image controls?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  12. #12
    Join Date
    May 2006
    Posts
    40
    Also, this is perhaps more addressed at paul, but should the database not be initialised via a method such as open as oppose to refresh?
    I can't recall if I've ever accessed a local DB so I'm unsure how to open one. But I know that the opening method and arguements passed affect how EOF and BOF return, e.g. adlockreadonly doesn't like to return EOF, etc.

    Is this perhaps the cause?
    J JJ

  13. #13
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    it opens the database when the form displays

    and then when you touch the arrow (mouse up settings) that is then when the code runs

  14. #14
    Join Date
    Dec 2003
    Posts
    2,750
    Quote Originally Posted by xnemsis
    Also, this is perhaps more addressed at paul, but should the database not be initialised via a method such as open as oppose to refresh?
    He's using a Data Control which means he has a persistent connection to the database.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Similar Threads

  1. Can't moveprevious with ADOdb. recordset
    By gill in forum VB Classic
    Replies: 4
    Last Post: 06-20-2002, 04:06 PM
  2. ADO MovePrevious error
    By rkbnair in forum VB Classic
    Replies: 1
    Last Post: 07-24-2000, 09:29 AM

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