G
Guest
I am using the code below on a form but for some reason when the previous or
First button is clicked while within a new record, it won't respond. ie. no
error, no movement. The form itself is set at open to disallow
edits/additions/deletions until an appropriate button has been selected
(edit/delete etc) at which time the property for the relevant action is
changed. I've tried gotorecord / runcommand variations and Last/Previous with
no luck. Am I just being thick and missing something obvious? Any help is
muchly appreciated.
Private Sub cmdprevious_Click()
On Error GoTo Err_cmdprevious_Click
Dim response As String
If Me.NewRecord Then
response = MsgBox("This record is not complete and will be lost if you
continue. Continue?", vbYesNo)
Select Case response
Case 7 'vbNo
Exit Sub
Case 6 'vbyes
Me.AllowDeletions = True
DoCmd.RunCommand acCmdDeleteRecord
Me.AllowDeletions = False
DoCmd.GoToRecord , , acPrevious
End Select
Else
DoCmd.GoToRecord , , acPrevious
End If
Exit_cmdprevious_Click:
Exit Sub
Err_cmdprevious_Click:
MsgBox Err.Description
Resume Exit_cmdprevious_Click
End Sub
First button is clicked while within a new record, it won't respond. ie. no
error, no movement. The form itself is set at open to disallow
edits/additions/deletions until an appropriate button has been selected
(edit/delete etc) at which time the property for the relevant action is
changed. I've tried gotorecord / runcommand variations and Last/Previous with
no luck. Am I just being thick and missing something obvious? Any help is
muchly appreciated.
Private Sub cmdprevious_Click()
On Error GoTo Err_cmdprevious_Click
Dim response As String
If Me.NewRecord Then
response = MsgBox("This record is not complete and will be lost if you
continue. Continue?", vbYesNo)
Select Case response
Case 7 'vbNo
Exit Sub
Case 6 'vbyes
Me.AllowDeletions = True
DoCmd.RunCommand acCmdDeleteRecord
Me.AllowDeletions = False
DoCmd.GoToRecord , , acPrevious
End Select
Else
DoCmd.GoToRecord , , acPrevious
End If
Exit_cmdprevious_Click:
Exit Sub
Err_cmdprevious_Click:
MsgBox Err.Description
Resume Exit_cmdprevious_Click
End Sub