473,656 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

forbid closing the form ?


Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoic e. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
5 2790
Put this code in the UnLoad event of your form:

If Me!CmdDeleteInv oice.Visible = True Then
MsgBox "Please Delete The Invoice Before Closing The Form",,"Attenti on!"
Cancel = True
Me!CmdDeleteInv oice.SetFocus
End If
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
"Peter yeshew" <fr*******@abv. bg> wrote in message
news:3f******** *************@n ews.frii.net...

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoic e. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
You may need rethink your structure. What's to stop a user from turning off
the computer? Will this break you app?

"Peter yeshew" <fr*******@abv. bg> wrote in message
news:3f******** *************@n ews.frii.net...

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoic e. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3
On Wed, 15 Oct 2003 11:11:42 -0500 in comp.databases. ms-access, "paii"
<pa**@packairin c.com> wrote:
You may need rethink your structure. What's to stop a user from turning off
the computer? Will this break you app?


It's impossible, haven't you seen Wargames? :-)

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #4
On 14 Oct 2003 16:02:54 GMT in comp.databases. ms-access, Peter yeshew
<fr*******@abv. bg> wrote:

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoic e. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?


If deleting the invoice is the only course of action that can be
accomplished then why have a button to do it? Just delete it in the
close event of the form.

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #5
My answer to your problem got posted as a new message and not a
follow-up to this one:

Yes, there is a way of forbidding a form being closed if you create a
boolean variable (blnCanClose) in the form's Open and Unload event. I
didn't read all the responses, but I have just such a form that cannot
be closed using the close button. They must first select a button,
then the form closes. Here's the skeleton code:

In general declarations of form: Dim blnCanClose As Boolean

Private Sub Form_Open(Cance l As Integer)
' make sure bln is always false when form is opened
' can't be closed until variable = true
blnCanClose = False
End Sub

Private Sub Form_Unload(Can cel As Integer)
If blnCanClose = False Then
MsgBox "Please Select a Date!"
' input person needs to select a date
' code then uses selected date to perform something
' call function or press a command button
Cancel = True
Else
Cancel = False
End If
End Sub

Private Sub cmdPerformFunct ion_Click()
' code for whatever you want performed from this form
' variable = true, form can now be closed after function executed
blnCanClose = True

' close the form after this button is pressed
DoCmd.Close acForm, Me.Name

End Sub

Trevor Best <bouncer@localh ost> wrote in message news:<6i******* *************** **********@4ax. com>...
On 14 Oct 2003 16:02:54 GMT in comp.databases. ms-access, Peter yeshew
<fr*******@abv. bg> wrote:

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoic e. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?


If deleting the invoice is the only course of action that can be
accomplished then why have a button to do it? Just delete it in the
close event of the form.

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4412
by: Michel | last post by:
Yes, there is a way of forbidding a form being closed if you create a boolean variable (blnCanClose = False) in the form's Unload event. I didn't read all the responses, but I have just such a form that cannot be closed using the close button. They must first select a button, then the form closes. Here's the skeleton code: Private Sub Form_Open(Cancel As Integer) ' bln is set to false when form is opened ' can't be closed until variable...
13
11387
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices Restaurant" etc. automatically and programmatically during data entry? This would eliminate my concatinated strings from producing errors when I base the string on a query. Think this is an example of the "Dreaded Apostrophe Bug." If I enter a...
1
5810
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the MDI child window. My application does certain logic when the user actually closes the MDI child form by clicking the "X" in the upper right hand. My application, however, should not execute this logic if the user closes the MDI parent. I...
1
2200
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
10
4008
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
2
3017
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then and then attempts to close the window (either via my custom 'Close' box or by clicking the close 'X' in the upper right window corner), the validation event still triggers and it tells the user that they have invalid data. Which of course means...
4
2994
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by another when its form Closing routine is run? I guess what I'm asking is will that work. If one form sets e.cancelled to true will e.cancel be true when the next form receives a closing event?
14
3357
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
2
4226
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate forms opening & closing. An example of this issue is as follows. I have a logon form open as the first thing. The main functional form opens when a user has successfully logged on. From the main form, a user should be able to logout which will...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.