A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Dialog box prevents record deleting



 
 
Thread Tools Display Modes
  #1  
Old September 17th, 2009, 12:57 PM posted to microsoft.public.access.tablesdbdesign
Rich Stone
external usenet poster
 
Posts: 52
Default Dialog box prevents record deleting

I have a database with standard record function buttons. However, my 'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialgog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas
  #2  
Old September 18th, 2009, 02:06 PM posted to microsoft.public.access.tablesdbdesign
Rich Stone
external usenet poster
 
Posts: 52
Default Dialog box prevents record deleting

Can anyone help please? This is really holding me up with my project now

"Rich Stone" wrote:

I have a database with standard record function buttons. However, my 'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas

  #3  
Old September 18th, 2009, 09:46 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Dialog box prevents record deleting

On Thu, 17 Sep 2009 04:57:02 -0700, Rich Stone
wrote:

I have a database with standard record function buttons. However, my 'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialgog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas


Can you verify that the user is indeed clicking the Yes button?

Do note that this code is seriously obsolete (the wizards are stuck back in
the last century). I'd suggest

Private Sub cmdDelete_Click()
Dim iAns As Integer
iAns = MsgBox("Are you sure you wish to delete the current record?", _
vbYesNo + vbExclamation)
If iAns = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
End Sub

Try putting a breakpoint on your x= line (in the VBA editor click in the grey
bar on the left of the editing window) and step through the code to see if
something unexpected is happning; also be sure you don't have SetWarnings set
to False somewhere (it would suppress warning messages about failed deletes).
--

John W. Vinson [MVP]
  #4  
Old September 18th, 2009, 11:50 PM posted to microsoft.public.access.tablesdbdesign
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Dialog box prevents record deleting

Rich

Are you using an MS Access "dialog" box, or are you referring to the message
box (MsgBox(...))?

How are you confirming that the row is not deleted?

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Rich Stone" wrote in message
...
I have a database with standard record function buttons. However, my
'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialgog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box
code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas



  #5  
Old September 21st, 2009, 08:18 AM posted to microsoft.public.access.tablesdbdesign
Rich Stone
external usenet poster
 
Posts: 52
Default Dialog box prevents record deleting

Thank you for your replies.

The button is on a form that shows each record at a time. I originally used
the wizard to create the delete button, hence the old coding. However, I did
change it to the revised method. I also have warnings off as I am using
custom dialog throughout the database.

The button works perfectly until I put the code in for the confirmation box
which doesn't make any sense as I've done this everywhere else in the
database with no problems at all.

I will first try turning the warnings back on. Then I will try to step
through the code and see what is happening. I have error catching in place
but there aren't any coming up!

"Jeff Boyce" wrote:

Rich

Are you using an MS Access "dialog" box, or are you referring to the message
box (MsgBox(...))?

How are you confirming that the row is not deleted?

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Rich Stone" wrote in message
...
I have a database with standard record function buttons. However, my
'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialgog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box
code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas




  #6  
Old September 21st, 2009, 08:24 AM posted to microsoft.public.access.tablesdbdesign
Rich Stone
external usenet poster
 
Posts: 52
Default Dialog box prevents record deleting

Thanks for your help. Please have a look at my other reply below.

"John W. Vinson" wrote:

On Thu, 17 Sep 2009 04:57:02 -0700, Rich Stone
wrote:

I have a database with standard record function buttons. However, my 'Delete'
button seems to have a problem. When I add vb code to bring up a custom
dialgog asking the user whether they definitely wish to delete the current
record, nothing happens after it. However, when I remove the dialog box code,
the record deletes immediately the button is pressed.

My code is as follows:

x = MsgBox("Are you sure you wish to delete the current record?",
vbYesNo + vbExclamation)
If x = vbNo Then
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Any ideas


Can you verify that the user is indeed clicking the Yes button?

Do note that this code is seriously obsolete (the wizards are stuck back in
the last century). I'd suggest

Private Sub cmdDelete_Click()
Dim iAns As Integer
iAns = MsgBox("Are you sure you wish to delete the current record?", _
vbYesNo + vbExclamation)
If iAns = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
End Sub

Try putting a breakpoint on your x= line (in the VBA editor click in the grey
bar on the left of the editing window) and step through the code to see if
something unexpected is happning; also be sure you don't have SetWarnings set
to False somewhere (it would suppress warning messages about failed deletes).
--

John W. Vinson [MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.