Hello, I need to create a button which when pressed will close currently active database, but before closing I need it to ask if I am sure or to go back to the form.
How can I do that?
Hello, I need to create a button which when pressed will close currently active database, but before closing I need it to ask if I am sure or to go back to the form.
How can I do that?
Hello.. Put this VBA on Command Button's On Click Event
If MsgBox("Are you sure?", vbYesNo + vbQuestion) = vbYes Then
DoCmd.Close
Else
'Something Function if you want to add
End If
Last edited by vdanelia; 03-01-2011 at 02:02 PM. Reason: Misstyped
This one closes the form when clicked Yes or No. I need it to close database, if clicked yes. And if clicked No I need it to ignore the click on button.
I edited the code below, I miss typed, Try this.... if something wrong post
DoCmd.Close - this line closes the form, can you edit this, so that it closes the database? I dont know the function name :/
Explain first, What do you want to close, table or form (What do you mean database) you want to exit from the access?
I want it to exit from the current active database, so that when I click Yes, it closes the database I am using currently.
Try this DoCmd.Quit acQuitPrompt
This one closes Access aswell, I just need it to close the database I am working with :P. I believe there is a macro built-in to access for it also.
ahhhhh I guessed what you neeed
Use this.. will work
DoCmd.CloseDatabase
Yes, that did it. Thanks a lot!