The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
The only problem is that once you press the exit database button it closes it straight away!
I want to create a nice little message box to ask whether you are sure you want to quit, I havn't got a clue howto do this and Access help is a pile of crap!
It's got to be an 'OK' or 'Cancel' box which is '1' or vbOKCancel...
Can someone either tell me how to assign a message box like that to a button or just upload a basic form with one button that does what I want so that I can see how it works...
I'm sure I'll find out somehow someday but I know someone here will be able to help me better and prevent me from ~buggering~ up my database... again...
Thanks!
try www.programmersheaven.com
The Visual Basic forum is full of experts who are more than willing to help.
Obviously the msg box needs close whatever you click. The statement 'end' in the 'if yes' statement will exit the program. Clicking 'no' merely exits the function and returns focus to the trigger (in this case the form).
Im using 'end' as an example. Its not hard to figure. You can replace it with other functionality if you wish (end the application, close db connections, scratch your **** etc etc etc).
MM, you must be using a different version of Access to me here, as i cant read it.
DW nearly got it!
The code reads:
If he clicks 'Yes' then display 'You clicked yes' and then close the diaogue box!
If he clicks 'No' then display 'you clicked no' and close the program!
I've sorted it out now and nicely edited it so that it all works! And looks good!
It's a pain, I've got to sufficiently edit the coding of the database away from the wizard stuff in access so that I can get more marks otherwise I can only get 50% marks...
I'll show you the code I finally used when I email the database home tomorrow just to show you how I managed to do it!
It's quite easy once you think about it!
b) looks like spaghetti
If you've downloaded the mdb I linked you too, copy the code from that, it's 3 lines :O)
I shoved the code that atg gave me in there and it all worked apart from one rather large problem!
Read the code again!
It all works fine, just he's made a mistake in what it does!
> just put it in the click event of the button. ie
>
>
> Sub Exit_database_Click()
> clicked = MsgBox("Do you want to quit?", vbYesNo +
> vbExclamation, "Confirm")
>
> If clicked = vbYes Then
> MsgBox ("You clicked yes")
> end
> Else
> MsgBox ("You clicked no")
> End If
> End Sub
*gags*
Sub Exit_database_Click()
clicked = MsgBox("Do you want to quit?", vbYesNo + vbExclamation, "Confirm")
If clicked = vbYes Then
MsgBox ("You clicked yes")
end
Else
MsgBox ("You clicked no")
End If
End Sub