Supress 'you are about to delete msg'

G

Guest

But, I know about setWarnings, and they are set, off then on.

I am capturing a Delete event, when the user clicks the row header in a
subform detail section, and allowing a delete under certain conditions. If
the condition is met, I do a Cancel = False. If they are not allowed to
delete, I do a Cancel = True.

Problem is that if I can do the delete, I also get the MS 'you are about to
delete' msg, at the very end of the proc, even tho the set warnings is set at
the beginning of the proc and the last line before the End Sub.

Maybe I should not have a setwarnings true anywhere in a Delete event???

My pertinent code is below, edited for space:

If isManagement() Then

DoCmd.SetWarnings False

With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]

Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You Sure?")

If Response = vbYes Then
Cancel = False
Else
Cancel = True
End If

End With

Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
Cancel = True

End If

DoCmd.SetWarnings True

End Sub
 
D

Douglas J. Steele

Where are you actually doing the delete? It's not between the
DoCmd.SetWarnings False and DoCmd.SetWarnings True as far as I can see.
 
R

RobFMS

Michael

This is from the help file:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)

' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue

' Display custom dialog box.
If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then
Cancel = True
End If

End Sub


In the help file, look under "Delete Event".

HTH

Rob Mastrostefano

--
FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

FMS Advanced Systems Group
http://www.fmsasg.com/
 
G

Guest

If you want to remove the messages for all queries, without using the set
warnings, then in the menu bar select
Tools > Options > Edit/Search (Tab) > Confirm Action Queries (remove the
selection)
Also remove the selection from the changes in record

But you have to know that it will never prompt with the message event when
you are using the queries dirrectly
 
G

Guest

See below for RobFMS, Ofer, and Doug resonses:

RobFMS
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
MM
Ah. I had looked under 'Delete Event', and Help would not take 'Event'.
But, I looked under Event and found it.
Am I correct, tho, that if the user had pressed the Delete key, that if I
don't Cancel the event, the record will be deleted?
I had originally used .Delete, since I had init-ed a Clone and set a
bookmark to my current record.
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]
...my confirm dialog msgbox>...
If Response = vbYes Then
.Delete 'Explicit Delete
Else
Cancel = True 'don't Delete
End If

End With

I took out the .Delete, cuz this event occurs after the user pressed the
Delete key. I think it deleted twice, when I had .Delete and then allowed
the Event to finish.
I'll go ahead and put in the before confirm delete, without a .Delete in my
IF statement, and see what happens.

I usually have the Access row

Doug
Where are you actually doing the delete?
MM
Since they already hit Delete, after clicking the row header, I assume that
Access will carry forward the delete, as long as I don't Cancel.

Ofer
remove the messages for all queries
MM
But, it's not a query, it's the Access Delete Event

Thank you all.

--
MichaelM


Michael Miller said:
But, I know about setWarnings, and they are set, off then on.

I am capturing a Delete event, when the user clicks the row header in a
subform detail section, and allowing a delete under certain conditions. If
the condition is met, I do a Cancel = False. If they are not allowed to
delete, I do a Cancel = True.

Problem is that if I can do the delete, I also get the MS 'you are about to
delete' msg, at the very end of the proc, even tho the set warnings is set at
the beginning of the proc and the last line before the End Sub.

Maybe I should not have a setwarnings true anywhere in a Delete event???

My pertinent code is below, edited for space:

If isManagement() Then

DoCmd.SetWarnings False

With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]

Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You Sure?")

If Response = vbYes Then
Cancel = False
Else
Cancel = True
End If

End With

Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
Cancel = True

End If

DoCmd.SetWarnings True

End Sub
 
G

Guest

The syntax I gave you wasn't exact, but I said also to remove the selection
from the Record changes (or as I sais in the first post "changes in record")

--
I hope that helped
Good Luck


Michael Miller said:
See below for RobFMS, Ofer, and Doug resonses:

RobFMS
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
MM
Ah. I had looked under 'Delete Event', and Help would not take 'Event'.
But, I looked under Event and found it.
Am I correct, tho, that if the user had pressed the Delete key, that if I
don't Cancel the event, the record will be deleted?
I had originally used .Delete, since I had init-ed a Clone and set a
bookmark to my current record.
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]
...my confirm dialog msgbox>...
If Response = vbYes Then
.Delete 'Explicit Delete
Else
Cancel = True 'don't Delete
End If

End With

I took out the .Delete, cuz this event occurs after the user pressed the
Delete key. I think it deleted twice, when I had .Delete and then allowed
the Event to finish.
I'll go ahead and put in the before confirm delete, without a .Delete in my
IF statement, and see what happens.

I usually have the Access row

Doug
Where are you actually doing the delete?
MM
Since they already hit Delete, after clicking the row header, I assume that
Access will carry forward the delete, as long as I don't Cancel.

Ofer
remove the messages for all queries
MM
But, it's not a query, it's the Access Delete Event

Thank you all.

--
MichaelM


Michael Miller said:
But, I know about setWarnings, and they are set, off then on.

I am capturing a Delete event, when the user clicks the row header in a
subform detail section, and allowing a delete under certain conditions. If
the condition is met, I do a Cancel = False. If they are not allowed to
delete, I do a Cancel = True.

Problem is that if I can do the delete, I also get the MS 'you are about to
delete' msg, at the very end of the proc, even tho the set warnings is set at
the beginning of the proc and the last line before the End Sub.

Maybe I should not have a setwarnings true anywhere in a Delete event???

My pertinent code is below, edited for space:

If isManagement() Then

DoCmd.SetWarnings False

With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]

Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You Sure?")

If Response = vbYes Then
Cancel = False
Else
Cancel = True
End If

End With

Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
Cancel = True

End If

DoCmd.SetWarnings True

End Sub
 
G

Guest

I see.
So, one way to delete is just to allow it to go through (without Cancelling
it), and if I want to permanently remove warnings, to do it in Options.

Ok. Will have to make a decision as to whether to do it permanently.
--
MichaelM


Ofer said:
The syntax I gave you wasn't exact, but I said also to remove the selection
from the Record changes (or as I sais in the first post "changes in record")

--
I hope that helped
Good Luck


Michael Miller said:
See below for RobFMS, Ofer, and Doug resonses:

RobFMS
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
MM
Ah. I had looked under 'Delete Event', and Help would not take 'Event'.
But, I looked under Event and found it.
Am I correct, tho, that if the user had pressed the Delete key, that if I
don't Cancel the event, the record will be deleted?
I had originally used .Delete, since I had init-ed a Clone and set a
bookmark to my current record.
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]
...my confirm dialog msgbox>...
If Response = vbYes Then
.Delete 'Explicit Delete
Else
Cancel = True 'don't Delete
End If

End With

I took out the .Delete, cuz this event occurs after the user pressed the
Delete key. I think it deleted twice, when I had .Delete and then allowed
the Event to finish.
I'll go ahead and put in the before confirm delete, without a .Delete in my
IF statement, and see what happens.

I usually have the Access row

Doug
Where are you actually doing the delete?
MM
Since they already hit Delete, after clicking the row header, I assume that
Access will carry forward the delete, as long as I don't Cancel.

Ofer
remove the messages for all queries
MM
But, it's not a query, it's the Access Delete Event

Thank you all.

--
MichaelM


Michael Miller said:
But, I know about setWarnings, and they are set, off then on.

I am capturing a Delete event, when the user clicks the row header in a
subform detail section, and allowing a delete under certain conditions. If
the condition is met, I do a Cancel = False. If they are not allowed to
delete, I do a Cancel = True.

Problem is that if I can do the delete, I also get the MS 'you are about to
delete' msg, at the very end of the proc, even tho the set warnings is set at
the beginning of the proc and the last line before the End Sub.

Maybe I should not have a setwarnings true anywhere in a Delete event???

My pertinent code is below, edited for space:

If isManagement() Then

DoCmd.SetWarnings False

With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]

Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You Sure?")

If Response = vbYes Then
Cancel = False
Else
Cancel = True
End If

End With

Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
Cancel = True

End If

DoCmd.SetWarnings True

End Sub
 
G

Guest

Ok, that worked. I just used Continue in the Form_BeforeDelConfirm, cuz my
-are you sure- dialog was in the Delete Event.

for our listeners:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
End Sub

I also have a delete button on the parent form, for this detail, which works
but always returns to the top of the detail, after its Delete takes place. I
would usually just make a call to that button, for a direct Delete from the
detail section, but I get very confuzed about referencing from the detail to
the parent (I've read everything here), and the button code currently goes
from the parent to the detail, so I thought it might be too difficult to
change the button code.

--
MichaelM


RobFMS said:
Michael

This is from the help file:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)

' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue

' Display custom dialog box.
If MsgBox("Delete this record?", vbOKCancel) = vbCancel Then
Cancel = True
End If

End Sub


In the help file, look under "Delete Event".

HTH

Rob Mastrostefano

--
FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

FMS Advanced Systems Group
http://www.fmsasg.com/


Michael Miller said:
But, I know about setWarnings, and they are set, off then on.

I am capturing a Delete event, when the user clicks the row header in a
subform detail section, and allowing a delete under certain conditions.
If
the condition is met, I do a Cancel = False. If they are not allowed to
delete, I do a Cancel = True.

Problem is that if I can do the delete, I also get the MS 'you are about
to
delete' msg, at the very end of the proc, even tho the set warnings is set
at
the beginning of the proc and the last line before the End Sub.

Maybe I should not have a setwarnings true anywhere in a Delete event???

My pertinent code is below, edited for space:

If isManagement() Then

DoCmd.SetWarnings False

With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.ProjectId.SetFocus
nParentProjectID = .[ParentProjectID]
nProjectID = .[ProjectId]
nItem = .[Item]

Response = MsgBox("This function will DELETE the CURRENT
ISSUE LINE, " & vbCrLf & _
"AND its associated CYCLE LINES!" &
vbCrLf & vbCrLf & _
"There is ***NO UNDO***!" & vbCrLf &
vbCrLf & _
"Parent Project ID: " &
nParentProjectID & vbCrLf & vbCrLf & _
"CONFIRM DELETE of Project #: " &
nProjectID & ", " & "and CURRENT Issue #: " & nItem & "?" _
, vbCritical + vbYesNo, "Are You
Sure?")

If Response = vbYes Then
Cancel = False
Else
Cancel = True
End If

End With

Else
MsgBox "Only BA's and Managers can delete an Issue line" & vbCrLf &
vbCrLf & _
"Please give the Project # and Issue # to a BA or Manager,
for deletion", vbExclamation, "User Not Authorized To Delete"
Cancel = True

End If

DoCmd.SetWarnings True

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