All
This is most likely a stupidly easy question, but my brain is mud (My first ever Access project I have been given is huge and complicated and learning as I go)
What I want to do is to have a message box prompt a user apon closing a form. With a YesNo option. If the user clicks yes, then the form is closed, if no then the form stays open.
I have tried Macros and VBA code for this. Also spend the last few days searching TheScripts and the Net, but not much luck.
Thanks
Martin
8 2336
Try this code behind a button:
IF msgbox ("Sure ?",vbYesNo) = vbYes then
docmd.quit
endif
This will close the database when the Yes is clicked, else nothing will happen.
Nic;o)
Howzit Nico5038
Thank you for the reply. I gave it a go and it works fine except that I only want to close/not close the form the user has open and not the whole database.
I will see if I can alter it slightly to do what I need to.
Thanks again
Martin
NeoPa 32,556
Expert Mod 16PB
I would suggest putting the code in the OnClose event, but then I saw there was no Cancel parameter :(.
You should be able to use the following code though, to quit just the current form. I have it on a command button. - Private Sub cmdExit_Click()
-
Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Name)
-
End Sub
Hi NeoPa
Thanks for your reply. Right I have tested it and it does work, it just does not do what I am after. I need a message box to prompt the user if they are sure they want to close the form or not, so they basically have a Yes/No or OK/Cancel option.
Thanks
Martin
Private Sub YourExitFormButton_Click()
If MsgBox("Are You Sure ?", vbYesNo) = vbYes Then
DoCmd.Close acForm, YourFormName
End If
End Sub
MissingLinq
That's the baby!!!! Thanks man, you just made my day.
Thanks a lot!!
NeoPa 32,556
Expert Mod 16PB
Sorry,
I was responding after you saw Nico's post.
I meant to put that code (the one line) in place of the .Quit in his code rather than replace it completely.
No harm done, you have all you need :)
I have now, thank you very much.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: js |
last post by:
Hi all,
I currently encounter a problem and it is urgent to me.
After calling the MsgBox.Show(), the message box is shown with non-modal
mode, what is the possible reason??? This only happen...
|
by: Lakrom |
last post by:
Hi to all, how to put msgbox in this asp page, this send me a message
Denied permission: 'MsgBox'
<% Set Conn=server.createobject("ADODB.connection")
Conn.open application("StrConRuta")
set rs =...
|
by: Lapchien |
last post by:
In this bit of code provided so helpfully by Nath:
Private Sub Command118_Click()
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.openrecordset("IMPORT")
|
by: CFW |
last post by:
I use the below code to move to the selected record in a list box to
that record in another form:
DoCmd.OpenForm "frmWorksheet", acNormal, , , acFormEdit,
acWindowNormal
rst.CursorLocation =...
|
by: Anne Richmond |
last post by:
I have just returned to my first vb.net project after a few weeks and find I
have a problem with Msgbox.
The commands I added earlier work OK but any new ones fail to show the
prompt value...
|
by: |
last post by:
I have about 20 MsgBox occurance in by program, which I use to inform the
user of the progress of the program, or ask confirmation of an action, or
simply to act separators to various parts of the...
|
by: Bob L |
last post by:
I've inserted a MsgBox in some VBScript on line 12 of an .asp page and get
the following error:
Microsoft VBScript runtime error '800a0046'
Permission denied: 'MsgBox'
/default.asp, line 12
...
|
by: Ivan Jericevich |
last post by:
In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?
If nonNumberEntered = True Then
msg = "Enter...
|
by: perkykoala |
last post by:
I apologize in advance for being REALLY detailed/verbose. It's the result of staring/tweaking code for too long.
Using VB 2005:
I need to design a multiple choice test (unfortunately, I can't...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |