Cancel Delete Problem

M

Max

Hi,

I have a nested form in Access 97 with a cancel delete option.
The problem I have is the records scroll up with the delete. If the delete
is cancelled then the records are not displayed and the user thinks the
record has been cancelled. I have tried moving the focus to the first record
but this code does not work except when the first record in the subform is
being deleted.

Any suggestions?
Thanks in advance

Max

The code as follows:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Cont CANCELDELETE = 2
Dim Answer

Response = acDataErrContinue ' Suppress default delete confirm
dialog box.
Answer = MsgBox("Are you sure you want to delete this record?", 1,
"Delete Warning")
If Answer = CANCELDELETE Then
Cancel = True
Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
DoCmd.GoToRecord , , acFirst
End If

End Sub
 
O

Ofer

Try writing it like that

If MsgBox("Are you sure you want to delete this record?", 1, "Delete
Warning") <> vbOK Then
Cancel = True
'Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
'DoCmd.GoToRecord , , acFirst
'DoCmd.GoToRecord acDataForm, "FormName", acFirst
End If
 
M

Max

Thanks for the feed back.
With the commented out lines it works the same as before.
With the ' removed it is still the same.
With the line

DoCmd.GoToRecord acDataForm, "PGIProcedureSub", acFirst

The error message reports that the form is not open even though the code is
running on the PGIProcedureSub form.

Max

Any further suggestions?
Ofer said:
Try writing it like that

If MsgBox("Are you sure you want to delete this record?", 1, "Delete
Warning") <> vbOK Then
Cancel = True
'Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
'DoCmd.GoToRecord , , acFirst
'DoCmd.GoToRecord acDataForm, "FormName", acFirst
End If

Max said:
Hi,

I have a nested form in Access 97 with a cancel delete option.
The problem I have is the records scroll up with the delete. If the
delete
is cancelled then the records are not displayed and the user thinks the
record has been cancelled. I have tried moving the focus to the first
record
but this code does not work except when the first record in the subform
is
being deleted.

Any suggestions?
Thanks in advance

Max

The code as follows:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Cont CANCELDELETE = 2
Dim Answer

Response = acDataErrContinue ' Suppress default delete confirm
dialog box.
Answer = MsgBox("Are you sure you want to delete this record?", 1,
"Delete Warning")
If Answer = CANCELDELETE Then
Cancel = True
Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
DoCmd.GoToRecord , , acFirst
End If

End Sub
 
M

Max

In case anyone has trouble with this I have the solution:

If MsgBox("Are you sure you want to delete this record?", 1, "Delete Warning
") <> vbOK Then
Cancel = True
SendKeys "{UP}{UP}" 'To reveal non-cancelled record.
End If


Max said:
Thanks for the feed back.
With the commented out lines it works the same as before.
With the ' removed it is still the same.
With the line

DoCmd.GoToRecord acDataForm, "PGIProcedureSub", acFirst

The error message reports that the form is not open even though the code
is running on the PGIProcedureSub form.

Max

Any further suggestions?
Ofer said:
Try writing it like that

If MsgBox("Are you sure you want to delete this record?", 1, "Delete
Warning") <> vbOK Then
Cancel = True
'Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
'DoCmd.GoToRecord , , acFirst
'DoCmd.GoToRecord acDataForm, "FormName", acFirst
End If

Max said:
Hi,

I have a nested form in Access 97 with a cancel delete option.
The problem I have is the records scroll up with the delete. If the
delete
is cancelled then the records are not displayed and the user thinks the
record has been cancelled. I have tried moving the focus to the first
record
but this code does not work except when the first record in the subform
is
being deleted.

Any suggestions?
Thanks in advance

Max

The code as follows:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As
Integer)
Cont CANCELDELETE = 2
Dim Answer

Response = acDataErrContinue ' Suppress default delete confirm
dialog box.
Answer = MsgBox("Are you sure you want to delete this record?", 1,
"Delete Warning")
If Answer = CANCELDELETE Then
Cancel = True
Forms![PGIQuick]![PGIQuickSub].Form![PGIProcedureSub].SetFocus
DoCmd.GoToRecord , , acFirst
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top