Basically I have made two buttons (next and previous) which navigate the results from a query on a form. What I want to do is make it so that the appropriate button is disabled when there is no next/previous record. Otherwise it goes on to the next set of results which I don't want it to do. How would I go about doing this, can I do it through access or would I have to add it to the VB code? current code:
Code: Private Sub cmdGotoPrev_Click() On Error GoTo Err_cmdGotoPrev_Click If Not CurrentRecord = 1 Then DoCmd.GoToRecord , , acPrevious End If Exit_cmdGotoPrev_Click: Exit Sub Err_cmdGotoPrev_Click: MsgBox Err.Description Resume Exit_cmdGotoPrev_Click End Sub Private Sub cmdGotoNext_Click() On Error GoTo Err_cmdGotoNext_Click If Not CurrentRecord = DCount("*", RecordSource) Then DoCmd.GoToRecord , , acNext End If Exit_cmdGotoNext_Click: Exit Sub Err_cmdGotoNext_Click: MsgBox Err.Description Resume Exit_cmdGotoNext_Click End Sub