Development Access Gurus - Disabling a button

Discussion in 'Software' started by Lazy, 9 Sep 2003.

  1. Lazy

    Lazy Meow?

    Joined:
    13 Nov 2001
    Posts:
    4,481
    Likes Received:
    1
    Basically I have made two buttons (next and previous) which navigate the results from a query on a form.

    What I want to do is make it so that the appropriate button is disabled when there is no next/previous record. Otherwise it goes on to the next set of results which I don't want it to do.

    How would I go about doing this, can I do it through access or would I have to add it to the VB code?

    current code:

     
  2. Risky

    Risky Modder

    Joined:
    10 Sep 2001
    Posts:
    4,386
    Likes Received:
    113
    Code:
    Private Sub cmdGotoPrev_Click()
    On Error GoTo Err_cmdGotoPrev_Click
    If Not CurrentRecord = 1 Then
        DoCmd.GoToRecord , , acPrevious
    End If
    
    Exit_cmdGotoPrev_Click:
        Exit Sub
    
    Err_cmdGotoPrev_Click:
        MsgBox Err.Description
        Resume Exit_cmdGotoPrev_Click
        
    End Sub
    
    
    
    Private Sub cmdGotoNext_Click()
    On Error GoTo Err_cmdGotoNext_Click
    
    If Not CurrentRecord = DCount("*", RecordSource) Then
        DoCmd.GoToRecord , , acNext
    End If
    
    Exit_cmdGotoNext_Click:
        Exit Sub
    
    Err_cmdGotoNext_Click:
        MsgBox Err.Description
        Resume Exit_cmdGotoNext_Click
        
    End Sub
    
     

Share This Page