Fisher
xTeam
If a Stamped Ever Happens to Run at You, Never Stop and Shout Jumangi, it Doesn't Work!!!!
Posts: 3,187
|
Post by Fisher on Jan 15, 2004 4:47:15 GMT -5
am workin with and access database, and i want to get a MsgBox to popup when i click the exit program button.....to get this i have to code it in VB, i cannot get it to work, neither can anyone i ask (useless:P lol)
ive tried to write it a few different ways, can anyone fix this?
MsgBox ("Are you sure you want to exit"), vbYesNo, Exit, = As VbMsgBoxResult vbOkOnly
MsgBox("Are you sure you want to Exit", vbYesNo) As VbMsgBoxStyle
MsgBox("Are You Sure U Want To Quit?", vbYesNo, "QUIT?" = vbYes
the last type lazer wrote, the other too are modifications of mines, i cant get it to work, anyone know?
|
|
|
Post by AbsoluteGenius on Jan 15, 2004 5:14:06 GMT -5
In VB it would be
If MsgBox("Are you sure you want to exit", vbQuestion + vbYesNo) = vbYes Then ' Your Exit Code here End If
|
|
Tewl
xTeam
C# & VB Developer
Posts: 495
|
Post by Tewl on Jan 15, 2004 6:47:38 GMT -5
If MsgBox("Are you sure you want to exit", vbQuestion + vbYesNo) = vbNo Then Cancel = True End If
|
|
Fisher
xTeam
If a Stamped Ever Happens to Run at You, Never Stop and Shout Jumangi, it Doesn't Work!!!!
Posts: 3,187
|
Post by Fisher on Jan 15, 2004 6:51:33 GMT -5
ok ty, the message box works now...
does anyone know the code forbr] yes = exit program no = do not exit program
the program i am using is microsoft access.
|
|
|
Post by equin0x on Jan 15, 2004 10:31:48 GMT -5
Private Sub Cmdexit_click() Dim exit1 As String
exit1 = MsgBox("Exit the program", vbYesNo) If exit1 = vbYes Then
Unload Me
End If
End Sub
like that?
|
|
|
Post by Dangermouse on Jan 15, 2004 14:56:02 GMT -5
You would have the button in the unload event of the form, the button would have Unload Me. if they click no then you set cancel = true, like in tewls example.
|
|
Fisher
xTeam
If a Stamped Ever Happens to Run at You, Never Stop and Shout Jumangi, it Doesn't Work!!!!
Posts: 3,187
|
Post by Fisher on Jan 19, 2004 10:41:38 GMT -5
nope none of its workin....maybe you dont understand what i mean lol.
i got an assignment in uni, its to create a database in MS Access, i have done all of that, but i have to finish my main menu (which i have created through a form in Access, NOT Visual Basic). i am using the Visual Basic Editor that is in Access, the code will be going into that.
the three examples i posted in my first post are what i have tried, i have tried tewls and it does give me the Message Box, unfortenually, it doesnt close the database when i click yes.
anyone know? or even understand me lol
|
|
|
Post by Lazer on Jan 19, 2004 12:09:29 GMT -5
works fine :-
Private Sub Command1_Click() If MsgBox("Are you sure you want to exit", vbQuestion + vbYesNo) = vbYes Then Unload Me End If End Sub
|
|
|
Post by equin0x on Jan 19, 2004 12:51:12 GMT -5
Mabey the unload me command dont work in Vba?
|
|
|
Post by Dangermouse on Jan 19, 2004 12:55:09 GMT -5
Try google Fisher.
Btw thats called VBA - Visual Basic for Applications
|
|
|
Post by Armstrong on Jan 19, 2004 14:55:22 GMT -5
Use br] Application.Quit
|
|
|
Post by AbsoluteGenius on Jan 21, 2004 6:48:41 GMT -5
Ok
on your form in access you have a command button that says exit?
in design mode, right click the button, select build event and make the code look like this
Private Sub Command0_Click() On Error GoTo Err_Command0_Click
If MsgBox("Do you want to quit", vbQuestion + vbYesNo, "Quit App") = vbYes Then DoCmd.Quit End If
Exit_Command0_Click[img]http://proboards8.com/boardimages/sad.gif[/img]br] Exit Sub
Err_Command0_Click[img]http://proboards8.com/boardimages/sad.gif[/img]br] MsgBox Err.Description Resume Exit_Command0_Click End Sub
|
|