473,785 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controlled Close with the "x" button and subform - is it hopeless?

I've been beating my head against this problem for the last several
days, and I haven't found a decent solution yet. So I'm turning to the
group for some moral support or better yet some answers.

Background:
I want the user to be able to close the form by using the "x" button
in the window title bar, I do not want to disable this. I have found a
nice solution in the Access Developer's Handbook that disables the
"x", however I am hoping to avoid using this solution since I like
having the "x" available to the user.

The form that needs the Controlled Close has a subform in datasheet
view; the subform is linked to the main form using the primary /
foreign key.

My question:
Under this scenario, has anybody made the controlled close to work? If
so, what is the general coding strategy?

I've gone through several iterations of code, here is a mock up of
where I've ended; btw it doesn't work very well, several errors result
in akward form handling.

Form_Load
'Nothing here related to controlled close

Form_Current
'Nothing here either

Form_BeforeUpda te
'Check for empty form
'If empty, exit sub
'Validate form
'If invalid Cancel = True, Exit Sub

Form_Unload
'Call Form_BeforeUpda te
'If invalid form then Cancel = True
'Repopulate form with user input
'Exit Sub

Function ValidateForm
'Check for empty form
'Various error checking
'Check for empty subform (note: user cannot access subform until all
required fields in
'parent form are completed
'Various error checking
'If invalid, returns False and sets mod variable strError to text
describing error

Form_Error
'If incomplete form error (2169) then
'Msgbox allow user to Save ('yes'), Not Save ('no'), or Cancel close
('cancel')
'If user wants to continue editing current record, then
'Prompt user with error msg from mod variable strError
'And set variables up to repopulate form with user input in Form_Unload
Jun 27 '08 #1
3 2230
Hi Kelii,

Just a passing thought, but perhaps the answer is to make the form
'borderless' (thin) and maybe modal. Then inside your form you add
your own [x] and title bar etc so that it 'looks' like the form you
desire. The difference here would be that the [x] is actually a
command button that you can assign code to.

The Frog
Jun 27 '08 #2
Frog,

Thanks for the suggestion. I just can't bring myself to do as you
suggest to the form. Not to be offensive, but it seems worse than
disabling the 'x' altogether. I keep thinking that all the other
commercial apps can do it, so why can't I?

Anyhow, I stumbled on a decent work around. I'd love to give the guy /
gal credit, but I can't seem to find the link again. Anyway here goes:

Main form
Declarations area:
'Setup a series of variables that can store the user's input (e.g.,
strDescription, sglQuantitiy)
'Setup variable indicating close is ok (e.g., strOkToClose,
blnOkToClose)

Form_BeforeUpda te
'Check for emtpy form, if so exit
'Validate form, if invalid Cancel = True, exit (this generates your
Form_Error)

Form_Unload
'Check if ok to close
'If not ok to close then restore input using variables from
declarations area
'Empty variables

Form_Error
'In addition to others, select case for DataErr 2169
'Prompt user for option to exit without save or cancel exit
'If exit without save, do so
'If exit with save, set variable to users input for restore in
Form_Unload

Subform:
Form_BeforeUpda te
'Various bits of code to validate input

That's it! Pretty simple. The only drawback is that in my design, you
get two prompts when you attempt to close using the 'x' and the data
in the form or subform is not valid. First you get the error prompt
from the Form_BeforeUpda te, then you get another prompt that asks if
you want to continue. In a perfect world, one could condense this into
one prompt; however I have not been able to do so.

Kelii
Jun 27 '08 #3
On Jun 2, 10:22*am, Kelii <kel...@yahoo.c omwrote:
I've been beating my head against this problem for the last several
days, and I haven't found a decent solution yet. So I'm turning to the
group for some moral support or better yet some answers.

Background:
I want the user to be able to close the form by using the "x" button
in the window title bar, I do not want to disable this. I have found a
nice solution in the Access Developer's Handbook that disables the
"x", however I am hoping to avoid using this solution since I like
having the "x" available to the user.

The form that needs the Controlled Close has a subform in datasheet
view; the subform is linked to the main form using the primary /
foreign key.

My question:
Under this scenario, has anybody made the controlled close to work? If
so, what is the general coding strategy?

I've gone through several iterations of code, here is a mock up of
where I've ended; btw it doesn't work very well, several errors result
in akward form handling.

Form_Load
'Nothing here related to controlled close

Form_Current
'Nothing here either

Form_BeforeUpda te
'Check for empty form
'If empty, exit sub
'Validate form
'If invalid Cancel = True, Exit Sub

Form_Unload
'Call Form_BeforeUpda te
'If invalid form then Cancel = True
'Repopulate form with user input
'Exit Sub

Function ValidateForm
'Check for empty form
'Various error checking
'Check for empty subform (note: user cannot access subform until all
required fields in
'parent form are completed
'Various error checking
'If invalid, returns False and sets mod variable strError to text
describing error

Form_Error
'If incomplete form error (2169) then
'Msgbox allow user to Save ('yes'), Not Save ('no'), or Cancel close
('cancel')
'If user wants to continue editing current record, then
'Prompt user with error msg from mod variable strError
'And set variables up to repopulate form with user input in Form_Unload
not sure what you mean by 'controlled close'
you have form A containing a subform B
and the user clicks 'x'
if subform B is dirty, what should happen ?
if form A is dirty, what should happen ?
Jun 27 '08 #4

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

Similar topics

7
7544
by: Bruce A. Julseth | last post by:
How do I emulate the web page "Close" Button, i. e. the "X" in the upper right hand corner of each web page? Thank you.... Bruce
4
20806
by: moose | last post by:
OK Popup window? No problem PDF in popup? No problem But what about a couple of Close Window buttons? Imagine a "Close Window" button at the top of the popup page. Then the PDF which can scroll. And another "Close Window" button at the bottom of the page. Any suggestions for completing this task?
5
2729
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available from the report print preview window. However, the first time I open the report to preview it the close button (X) in upper right hand corner is there. When I close the preview and open it again it is not there unless I close the app down and...
4
3516
by: mhifd009 | last post by:
I have disabled a close button in the property section of a form (FRM1), as i open the form the close button has gone (i have programmed close button), but as i close the form, the form that opened FRM1 also has the close button disabled - and so does every form until i minimise a form and maximise again. I have also tried to disable controlbox property but doesnt seem to remove, min, max or close - is there somewhere else i need to set. ...
0
2649
by: bloombloom | last post by:
I am gonna post my AS in hopes that someone can get a good understanding of what i am doing. So here is the code: t1.onRelease = function() { infoField._visible = true; startLoading("cc11.swf"); }; t2.onRelease = function() { infoField._visible = true; startLoading("cc11.swf"); };
3
2307
by: mfleet1973 | last post by:
Hi. Visual Studio 2003. Is there a way to disable another application's form's close button that is on the taskbar? Cheers. Mike.
2
2320
by: Carla Simeoni | last post by:
Assume I have an open Form. Then I click the "normal" window "X" icon (=Close button). How do I assign a function in Form.cs to this event ? In other words if this Form/window is closed I want to perform some exit statements. When I doubleclick on a "normal" button I am autoamtically taken from the designer pane into the source code editor pane and a new function is automatically inserted. This is not the case for a system button like...
2
3363
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. The report opens fine. It opens maximized as one would expect. However, the report preview window's close button is disabled which is confusing to my users (they have to click the resize button on the preview window which then restores the close...
0
2384
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
5
5893
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
0
10324
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
10147
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...
0
9949
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
8971
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
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
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.