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 / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

Stop Button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neil Greenough - 04 May 2005 12:08 GMT
I have included a stop button on a form to exit a database. The code for
this is

Private Sub QuitApplication_Click()
On Error GoTo Err_QuitApplication_Click

   DoCmd.Quit

Exit_QuitApplication_Click:
   Exit Sub

Err_QuitApplication_Click:
   MsgBox Err.Description
   Resume Exit_QuitApplication_Click

End Sub

I want it so that, when it is clicked, a message box appears saying "Are you
sure you want to exit?" With a yes or no answer.

Anybody able to edit my code for me pretty please with jelly tots?
Alex White MCDBA MCSE - 04 May 2005 12:17 GMT
Hi Neil,

if Msgbox("Are you sure you want to
exit?",vbyesno+vbquestion,"Confirmation")=vbyes then
   docmd.quit
end if

should do the trick....
Signature

Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

>I have included a stop button on a form to exit a database. The code for
>this is
[quoted text clipped - 17 lines]
>
> Anybody able to edit my code for me pretty please with jelly tots?
Neil Greenough - 04 May 2005 12:52 GMT
Thanks Alex.

Where about should I be adding that additional code? At the beginning of the
original code or.....? Do I need to delete anything from the original code?

> Hi Neil,
>
[quoted text clipped - 25 lines]
>>
>> Anybody able to edit my code for me pretty please with jelly tots?
Alex White MCDBA MCSE - 04 May 2005 13:04 GMT
Hi Neil,

just wrap the

if msgbox....

end if

around the code you want to run under that condition.

e.g

Private Sub QuitApplication_Click()
   On Error GoTo Err_QuitApplication_Click

   if Msgbox("Are you sure you want to
exit?",vbyesno+vbquestion,"Confirmation!")=vbyes then
      DoCmd.Quit
   end if

Exit_QuitApplication_Click:
  Exit Sub
Err_QuitApplication_Click:
   MsgBox Err.Description
   Resume Exit_QuitApplication_Click
End Sub

Does that answer your question?

you may want to try either of these as they may save you being prompted on
other issues when closing.

DoCmd.Quit acQuitSaveAll

DoCmd.Quit acQuitSaveNone

Signature

Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

> Thanks Alex.
>
[quoted text clipped - 31 lines]
>>>
>>> Anybody able to edit my code for me pretty please with jelly tots?
Neil Greenough - 04 May 2005 13:40 GMT
Alex,

It works a treat! Thanks!

Neil

> Hi Neil,
>
[quoted text clipped - 67 lines]
>>>>
>>>> Anybody able to edit my code for me pretty please with jelly tots?
 
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



©2008 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.