I have created navigation buttons in a form to move to First, Next, Previous, Last and New records. I want to disable certain buttons when certain records are current. I am having difficulty with the Last button. When I click it, I want the Next button to be disabled but it remains enabled.
Here is a summary of the code:
Declarations:
Dim recClone as Recordset
Set recClone = Me.RecordsetClone()
I have tried two different codes to make this happen:
1)
recClone.MoveNext
If recClone.EOF = True Then
cmdNext.Enabled = False
Else
cmdNext.Enabled = True
End If
recClone.MovePrevious
2)
recClone.MoveNext
cmdNext.Enabled = Not (recClone.EOF)
recClone.MovePrevious
I get the same results from both codes: the cmdNext button is not disabled.
With the cmdFirst button I use this code:
recClone.MovePrevious
If recClone.BOF = True Then
cmdPrevious.Enabled = False
Else
cmdPrevious.Enabled = True
End If
reClone.MoveNext
This code successfully disables the cmdPrevious button. The only thing I can think of is that there is a blank record after the last record which is essetially a new record and I wonder if that has anything to do with the problem.
I wrote code to disable the cmdNext button when I click on the cmdNew button and that works correctly.
I got the code from a programming book and it works perfect in the example database they use (of course).
Any ideas??
Here is a summary of the code:
Declarations:
Dim recClone as Recordset
Set recClone = Me.RecordsetClone()
I have tried two different codes to make this happen:
1)
recClone.MoveNext
If recClone.EOF = True Then
cmdNext.Enabled = False
Else
cmdNext.Enabled = True
End If
recClone.MovePrevious
2)
recClone.MoveNext
cmdNext.Enabled = Not (recClone.EOF)
recClone.MovePrevious
I get the same results from both codes: the cmdNext button is not disabled.
With the cmdFirst button I use this code:
recClone.MovePrevious
If recClone.BOF = True Then
cmdPrevious.Enabled = False
Else
cmdPrevious.Enabled = True
End If
reClone.MoveNext
This code successfully disables the cmdPrevious button. The only thing I can think of is that there is a blank record after the last record which is essetially a new record and I wonder if that has anything to do with the problem.
I wrote code to disable the cmdNext button when I click on the cmdNew button and that works correctly.
I got the code from a programming book and it works perfect in the example database they use (of course).
Any ideas??