Results 1 to 5 of 5

Thread: EOF not working right for me

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    EOF not working right for me

    Hello, in my program I have a Next and Previous button. If for example I have 14 records in my access database, I want the next button to disable itself on the 14th record (or last one). I tried the following code but it does not disable itself until one after the last entry.

    VB Code:
    1. Private Sub cmdNext_Click()
    2.    
    3.     Adodc1.Recordset.MoveNext
    4. If Adodc1.Recordset.EOF = True Then
    5.     cmdNext.enabled = false
    6. End If
    7. End Sub

    I have also tried the following but it did not work:
    VB Code:
    1. Private Sub cmdNext_Click()
    2.    
    3. If Adodc1.Recordset.EOF = True Then
    4.     cmdNext.enabled = false
    5. else
    6. Adodc1.Recordset.MoveNext
    7. End If
    8. End Sub
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: EOF not working right for me

    If you don't include the "if" part, does it eventually give you an error? In other words, does it ever reach the EOF?

  3. #3
    Hyperactive Member Granty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    439
    Private Sub cmdNext_Click()

    Adodc1.Recordset.MoveNext
    If Adodc1.Recordset.EOF = True Then
    cmdNext.enabled = false
    Adodc1.Recordset.MoveLast

    End If
    End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419
    mendak, when I take away the If/Then statements, I get an error 'Compile Error: Cant assign to Read Only Property" If it is talking about my access file being Read-Only, it isn't.

    Granty, I tried that code and it did not work, when I get to the last record, the cmdNext.enabled = true. If I push the button again, it will then make the button disabled.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  5. #5
    Lively Member
    Join Date
    Jun 2003
    Posts
    114
    That is correct. When you're on the last/first record EOF/BOF are gonna be false ... You should try to implement a record count and perform your enable/disable using a record count and position ...

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