Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

Msg box to appear before deleting a record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 11 Jan 2008 12:28 GMT
hello

i have a form which i have added a delete button to!

however i want to have a msg box apear prior to the record being deleted
asking 'do you want to delete record' with a yes / no buttons and if the
answer is no then its not deleted if yes then is is deleted!

Please help !!! as its driving me made
Signature

Thanks Steve

Wayne-I-M - 11 Jan 2008 13:58 GMT
Hi Steve

Try this (change the messages to what you want) take off the "else" if you
don't want it.

Private Sub Button_Click()
DoCmd.SetWarnings False
If MsgBox("Do you really want to delete this record?", vbQuestion + vbYesNo)
= vbYes Then
   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Else
   MsgBox "OK it's not been cancelled"
End If
DoCmd.SetWarnings True
End Sub

Signature

Wayne
Manchester, England.

> hello
>
[quoted text clipped - 5 lines]
>
> Please help !!! as its driving me made
smason - 11 Jan 2008 15:12 GMT
Hello

thanks for the reply
how ever i am getting an error on this line
If MsgBox("Do you really want to delete this record?", vbQuestion + vbYesNo)
= vbYes Then

is is red!

any ideas

> Hi Steve
>
[quoted text clipped - 22 lines]
> >
> > Please help !!! as its driving me made
Wayne-I-M - 11 Jan 2008 16:08 GMT
It's on one line - this forum text box sometimes shortens lines -  make sure
that

If MsgBox("Do you really want to delete this record?", vbQuestion + vbYesNo)
= vbYes Then

(Mind you - you may say "that" one one line as well - oh well)

Signature

Wayne
Manchester, England.

> Hello
>
[quoted text clipped - 33 lines]
> > >
> > > Please help !!! as its driving me made
smason - 11 Jan 2008 15:35 GMT
sorry it worked perfectly
i am stupid!

> Hi Steve
>
[quoted text clipped - 22 lines]
> >
> > Please help !!! as its driving me made
Maurice - 11 Jan 2008 14:08 GMT
Try somehting like this:

private sub button_click
dim iChoice as Integer

iChoice= msgbox("Do you want to delete?", vbYesNo)

Select Case iChoice
 Case=6
   DoCmd.DoMenuItem acFormbar, acEditMenu, 8, ,acMenuVer70
   DoCmd.DoMenuItem acFormbar, acEditMenu, 8, ,acMenuVer70
 Case = 7
   '-> do what you want to do in case of No...
End Select

end sub

The docmd. option is a wizard generated piece of code while creating a  
deletebutton with the wizard.

hth
Signature

Maurice Ausum

> hello
>
[quoted text clipped - 5 lines]
>
> Please help !!! as its driving me made
smason - 11 Jan 2008 15:21 GMT
Hello Maurice

thanks for the reply

however when i tried this the message box came up but it didn't delete the
record!
also what could i do if the answer is no how would i just leave the record
there!

any ideas !!!

thanks in advance

> Try somehting like this:
>
[quoted text clipped - 27 lines]
> >
> > Please help !!! as its driving me made
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.