Keith Nichols
Registered User.
- Local time
- , 01:58
- Joined
- Jan 27, 2006
- Messages
- 431
Hi,
Hope this is a nice and simple one. I know I have seen various "last record" references in various threads but I couldn't find one in a search.
I have a command button on my form which navigates you to the next record. I use this rather than the navigation buttons as I can set the tab order to go to it after all the fields are filled. This works fine unless the form is on the last record, in which case it throws up an error. To get round this, I want to test that the current record is not the last record.
It is the test in the If statement I need help with. How do I check that the current record is not the last record in my form? I think it will use the dcount but I don't know how.
Private Sub cmd_Next_Record_Click()
On Error GoTo Err_cmd_Next_Record_Click
If (current record < dcount) then
DoCmd.GoToRecord , , acNext
Else
DoCmd.GoToRecord , , acFirst
End If
Exit_cmd_Next_Record_Click:
Exit Sub
Err_cmd_Next_Record_Click:
MsgBox Err.Description
Resume Exit_cmd_Next_Record_Click
End Sub
Thanks in advance.
Keith.
Hope this is a nice and simple one. I know I have seen various "last record" references in various threads but I couldn't find one in a search.
I have a command button on my form which navigates you to the next record. I use this rather than the navigation buttons as I can set the tab order to go to it after all the fields are filled. This works fine unless the form is on the last record, in which case it throws up an error. To get round this, I want to test that the current record is not the last record.
It is the test in the If statement I need help with. How do I check that the current record is not the last record in my form? I think it will use the dcount but I don't know how.
Private Sub cmd_Next_Record_Click()
On Error GoTo Err_cmd_Next_Record_Click
If (current record < dcount) then
DoCmd.GoToRecord , , acNext
Else
DoCmd.GoToRecord , , acFirst
End If
Exit_cmd_Next_Record_Click:
Exit Sub
Err_cmd_Next_Record_Click:
MsgBox Err.Description
Resume Exit_cmd_Next_Record_Click
End Sub
Thanks in advance.
Keith.