Simple VB if/else structure to quit application?

Sharky II

Registered User.
Local time
Today, 10:16
Joined
Aug 21, 2003
Messages
354
Hi guys

I found some code on this forum (thanks to richmorrison) to help bring up a pop up for when the user quits the database:

Code:
Private Sub Form_Unload(Cancel As Integer)
Dim intReturn As Integer
intReturn = MsgBox("Do you want to quit application ?", vbYesNo, "Quit ?")
If (intReturn = vbYes) Then
Else
Cancel = True
End If
End Sub

this is great, but 'access' is still open. all i wanna do is add a DoCmd.Quit after the 'Then' but it won't have any of it.

I'm sure i just have syntax wrong (i'm a java programmer, not exactly great at access!) - can anyone help?

Cheers
 
like for example, i want another conditional structure for deleting a record from a form - if the user makes a mistake or wants to delete a record, i've added a 'delete record' button, but i want it to have a 'are you sure? ok/cancel' structure, but i can't get it to work!

always the simple things :rolleyes:

Cheers
 
re the last post - ok it does this for you :D however if you click 'no', then it says

'The DoMenuItem action was cancelled'

Any way to get rid of this?

Ok i'll stop talking to myself now :p
 
Hi Ed,

Code:
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Do you want to quit application ?", vbYesNo, "Quit ?") = vbYes Then
   DoCmd.Quit
Else
   Cancel = True
End If
End Sub

Wayne
 
Hi wayne

Once again, you've helped me out!

Cheers mate

Eddie
 

Users who are viewing this thread

Back
Top Bottom