This actually makes sense. If it's on Record #1 and it thinks there are only 1 record(s), then
- If Me.CurrentRecord >= Me.Recordset.RecordCount Then
will evaluate to True, disabling your fields.
You could try something like the following:
- On Error Resume Next
-
Dim oClone As Recordset
-
Set oClone = Me.RecordsetClone
-
oClone.MoveLast
-
-
If Me.CurrentRecord = 1 Then
-
Me.cmdPrevious.Enabled = False
-
Me.cmdFirst.Enabled = False
-
Else
-
Me.cmdPrevious.Enabled = True
-
Me.cmdFirst.Enabled = True
-
End If
-
If Me.CurrentRecord >=
oClone.RecordCount
Then -
Me.cmdNext.Enabled = False
-
Me.cmdLast.Enabled = False
-
Else
-
Me.cmdNext.Enabled = True
-
Me.cmdLast.Enabled = True
-
End If
This should make a copy of the Form's RecordSet and then move to it's end, somewhat forcing it to load completely, at least load completely into the Clone.
Lastly, this line will act differently depending on if you can Add records to your Form:
- If Me.CurrentRecord >= Me.Recordset.RecordCount Then
The .CurrentRecord for the New Record will be the RecordCount + 1.
You may want to flip flop the If Statement:
- If Me.CurrentRecord < oClone.RecordCount Then
-
-or when new records can be added-
-
If Me.CurrentRecord <= oClone.RecordCount Then
-
Me.cmdNext.Enabled = True
-
Me.cmdLast.Enabled = True
-
Else
-
Me.cmdNext.Enabled = False
-
Me.cmdLast.Enabled = False
-
End If