**navigation buttons**

MS_Access_Amature

Registered User.
Local time
Today, 15:11
Joined
Nov 10, 2010
Messages
56
TxtRecordNumber: ControlSource = CurrentRecord
TxtRecordCount: ControlSource = Count(*)


Private Sub ButtonNextRecord_Click()
On Error GoTo MyErrorControl

If Me.CurrentRecord = Me.Count Then
Me![ButtonLastRecord].Enabled = False
Me![ButtonPreviousRecord].SetFocus
Me![ButtonNextRecord].Enabled = False
Else
DoCmd.GoToRecord , , acNext
End If

Exit Sub
MyErrorControl:
Select Case Err.Number
Case 0
Resume Next
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "ButtonNextRecord_Click ERROR"
Resume Next
End Select
End Sub


When I click ButtoNextRecord, it allows CurrentRecord to go passed the Count as if to create a new record. It'll be something like txtRecordNumber = 3 and txtRecordCount = 2. I want to disable the button when it gets to 2 = 2. In other words don't allow it to create a new record by clicking the ButtonNextRecord. What do I have to do??
Thanks in advanced.
 
The simple solution is set the Form's Allow Additions property to no. Only set to Yes when your new button is click.
 

Users who are viewing this thread

Back
Top Bottom