I have created a Next button to move to the next record on my form. I want the Next button to become invisible when the form is on the last record. The simplest way to figure out if the current record was the last one was to compare Me.CurrentRecor d to Me.Recordset.Re cordCount. Here is my code:
When my Next button didn't become invisible, I added the Debug.Print lines to make sure that the numbers were what I would expect. They were. However, when both Me.CurrentRecor d and Me.Recordset.Re cordCount equaled 3, it still jumped to the Else portion and executed lines 9 and 10. That is what I don't understand. I checked to make sure that the values returned were of the same type, (which they were) but then I realized that if one returned a text and the other a long, then I would get a type mismatch error. I'm guessing that there is some logical explanation of why these can't be compared in this way, but I can't figure it out.
If it makes any difference, the code I'm using to move to the next record is:
Not sure if this triggers the OnCurrent event slightly different that would affect the record counting (I don't think so, but just want to provide the information in case it does make a difference).
Code:
Private Sub Form_Current()
Debug.Print Me.Recordset.RecordCount
Debug.Print Me.CurrentRecord
If Me.CurrentRecord = Me.Count Then
Me.cmdFinish.Enabled = True
Me.cmdNext.Visible = False
Else
Me.cmdFinish.Enabled = False
Me.cmdNext.Visible = True
End If
End Sub
If it makes any difference, the code I'm using to move to the next record is:
Code:
Me.Recordset.MoveNext
Comment