G
glen.welsh
I am trying to keep a database from creating new records when the
"next" button is activated at the end of records. I have written the
following code to deactivate the "next" and "last" buttons when the
last record is found. It works, but if I click the next button too
fast, it deactivates before reaching the last record. Any suggestions
are welcome and appreciated.
Private Sub cmdNext_Click()
On Error GoTo Err_Command283_Click
If Me.CurrentRecord >= counter.VALUE - 1 Then
Me.cmdPrevious.Enabled = True
Me.cmdPrevious.SetFocus
Me.cmdFirst.Enabled = True
Me.cmdNew.Enabled = True
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False
Else
Me.cmdPrevious.Enabled = True
Me.cmdFirst.Enabled = True
Me.cmdNew.Enabled = True
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True
End If
DoCmd.GoToRecord , , acNext
Exit_Command283_Click:
Exit Sub
Err_Command283_Click:
MsgBox Err.Description
Resume Exit_Command283_Click
End Sub
"next" button is activated at the end of records. I have written the
following code to deactivate the "next" and "last" buttons when the
last record is found. It works, but if I click the next button too
fast, it deactivates before reaching the last record. Any suggestions
are welcome and appreciated.
Private Sub cmdNext_Click()
On Error GoTo Err_Command283_Click
If Me.CurrentRecord >= counter.VALUE - 1 Then
Me.cmdPrevious.Enabled = True
Me.cmdPrevious.SetFocus
Me.cmdFirst.Enabled = True
Me.cmdNew.Enabled = True
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False
Else
Me.cmdPrevious.Enabled = True
Me.cmdFirst.Enabled = True
Me.cmdNew.Enabled = True
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True
End If
DoCmd.GoToRecord , , acNext
Exit_Command283_Click:
Exit Sub
Err_Command283_Click:
MsgBox Err.Description
Resume Exit_Command283_Click
End Sub