I have a function called "Buttons" that enables / disables "First, Last., Previous, Next" buttons depending on the current record.
This works fine with various tables except one.
The call to "Buttons" is in the form's current event.
The table in question has 8280 records but the form.currentrecord, after clicking the "Last" button, shows 8729 records.
The variable "db" has the name of the table to be processed.
Why is it so?
Code below.
The images show, in order, the buttons after the "last" and "First" buttons are clicked and a message box that shows the currentrecord number after the "First" and "Last" buttons are clicked. In the first screen shot the "Last" and "Next" buttons should be disabled.
I have tried a "Compact and Repair" but the problem persists.
This works fine with various tables except one.
The call to "Buttons" is in the form's current event.
The table in question has 8280 records but the form.currentrecord, after clicking the "Last" button, shows 8729 records.
The variable "db" has the name of the table to be processed.
Why is it so?
Code below.
Code:
Private Sub btnLast_Click()
DoCmd.GoToRecord , , acLast
End Sub
Public Sub Buttons(db As String)
Dim frm As Form
Dim btnOKP As Boolean
Dim btnOKN As Boolean
Set frm = Screen.ActiveForm
btnOKP = True
btnOKN = True
If (frm.CurrentRecord = 1 Or frm.NewRecord) Then
btnOKP = False
End If
msgbox frm.CurrentRecord & " " & DCount("*", db)
If (frm.CurrentRecord = DCount("*", db) Or frm.NewRecord) Then
btnOKN = False
End If
With frm
.btnPrevious.Enabled = btnOKP
.btnFirst.Enabled = btnOKP
.btnNext.Enabled = btnOKN
.btnLast.Enabled = btnOKN
End With
End Sub
[ATTACH type="full"]105391[/ATTACH][ATTACH type="full"]105392[/ATTACH][ATTACH type="full"]105393[/ATTACH][ATTACH type="full"]105394[/ATTACH]
The images show, in order, the buttons after the "last" and "First" buttons are clicked and a message box that shows the currentrecord number after the "First" and "Last" buttons are clicked. In the first screen shot the "Last" and "Next" buttons should be disabled.
I have tried a "Compact and Repair" but the problem persists.