Database Form Navigation using command buttons for moveNext etc
Posted on 2003-12-05
I am using Access 2002 and VBA
I have added buttons to a form to navigate through the records using the four common options moveNext MovePrevious, MoveLast, MoveFirst and AddNewRecord.
linking the onClick event procedure like this:
Private Sub cmdMoveNext_Click()
DoCmd.GoToRecord , , acNext
This works fine to allow me to work through the records, but I need to make the coding more robust to prevent errors appearing when:
trying to move to the record before the first record
trying to move to the record after the add new record
The coding needs to incorporate options to disable the buttons
i.e. disable the buttons using cmdMovePrevious.enabled = false when sitting on the first record
The coding must work using ADO.
I will be grateful for any tips and advice