Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ctrl alt del, prevent this from closing form

Status
Not open for further replies.

laruajo

MIS
Sep 16, 2002
24
US
I have placed code on the Unload event of a form to check if certain fields have data in them (once the user has started entering in data), if not the form will not close. However, I have realized that ctrl alt del, allows them to close the form with only half the data in it. This is causing holes in the table, records with only half the info. Is there any way I can prevent ctrl alt del from closing the database?

Thanks in advance.
Laura

 
Check out faq702-1870. If explains how to prevent a database from being close except by a button (or other method) you provide.... Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Thanks but the link to that didn't work. It gave me this message "You have requested an area that is currently undefined. Please hit the back button to go back. "
 
It is a FaQ I wrote in the Forms Forum. I know that Tek-Tips is currently experiencing technical difficulties, so you could try going to Access: Forms, then the FAQ button, then look in Security Area and Look for Control Closing of Form Or Application.... Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Unfortunately, no luck here, it is still closing when I use Ctrl+Alt+Del. I have a few questions though that may be the reason it did not work. I do not have a close button on my form so I did not place
OK2Close = True
DoCmd.Close

anywhere in the code. Once data is entered the users presses a button which takes them to a form where they get a number. When that form is opened, it automatically closes the form they were on. Secondly, I already have code in the Unload event of the form so I was not sure where to place: Cancel = Not OK2Close

Here is my code in the Unload event:
If IsNull(Me.[Part #]) Then
MsgBox "Part Num cannot be null, Please enter the appropriate data"
DoCmd.GoToControl "Part #"
Cancel = True
Else
If IsNull(Me.[Work Order #]) Then
MsgBox "Work Order # Num cannot be null, Please enter the appropriate data"
DoCmd.GoToControl "Work Order #"
Cancel = True
Else
If IsNull(Orig_Employee_Num) Then
MsgBox "Emp Num cannot be null, Please enter the appropriate data"
DoCmd.GoToControl "Orig Employee Num"
Cancel = True
Else
If IsNull(Me.[Heat Num, Serial Num, Etc]) Then
MsgBox "Heat Num, Serial Num cannot be null, Please enter the appropriate data"
DoCmd.GoToControl "Heat Num, Serial Num, Etc"
Cancel = True

Any further help would be appreciated. Thank you.
Laura
 
Well, Without those lines you omited, this procedure will not work.......

But now that I think about it...this will not prevent a ctrl+alt+del close anyway.....At least I don't think.

The ctrl+alt+del does not go through normal "closing" procedures, because Windows just kills the threads and process.....Access never evn has control of this....

You best solution to this problem is going to be user training in my opinion. Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
We conducted user training sessions a few weeks ago and explained to them that they must fill in all required fields before closing the form. I thought I had found every possible way they could close the form with partial info and added code to prevent that from happening, but I guess not. Thanks for the help.

Anyone else with a suggestion??
 
Hi

How about firing anyone why does it?, probably will not need to fire more than one before the rest get the message.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
While firing people would work, I don't think it is an option!!!

Someone mentioned something on another site about creating a macro called Autokeys, and using it to disable Delete. Does anyone know anything about Autokeys macros??
 
Yeah, there's no way to block ctrl-alt-del without getting pretty heavily into windows programming. It's sort of like asking how you can make it so that turning off the computer won't close the form--it's just happening at a lower level than that on which Access operates, and Access won't be able to stop that.

On the other hand, if people are doing this regularly and it is causing problems with your data, there are two angles I would investigate.

1) This one may sting a bit, but the question here is, are people doing this because they are getting frustrated working with your forms? If people are feeling the need to do something that is so likely to make their PC unstable, is it possible that the form is putting an onerous burden on the users? Clearly I have no idea what your form is like, and it may well be small, quick, and easy to use. But this is the first thing I would think to check into.

2) You could make the form and unbounded form. This won't prevent users from closing the form, but it will prevent the closing of the form from doing any harm to that particular table (or tables, if it's based on a query).

Unbound forms are very powerful, but a good bit of work. You may already know your way around them, but for the benefit of anyone reading this who doesn't, here's a (tiny) explanation.

Bound forms have a RecordSource, a table of query where they get their data, and each control on a bound form has a ControlSource, the name of one of the fields in that RecordSource.

When you move from record to record, Access knows where to get the data to display for the record because of the bindings. Also, because it knows how to display info, it also knows how to save it back to the table. This allows it to automatically save a record every time you move to another record.

Unbound forms have no recordSource, and their controls have no ControlSource. This means that you have to do the displaying and saving of records in code, and navigating from one record to another, too.

When you go to a new record, or open a form and display the first record, your code creates a recordset that retrieves the data for that record and puts the data from each field into the appropriate control. Saving is done manually, too. If you want to save a record you do the whole thing in reverse: make a recordset and save from the controls to the recordset.

This arrangement means a few things. You have to make your own navigation buttons. This is more work, like everything on an unbound form, but it allows you to control such things as whether or not saving will happen--you can just do it, or, if you want, you can prompt the user to find out if she wants to do it.

It also means that you can put an explicit "save" button on your form, which lets the user feel a little more in control.

But the biggest advantage, by far, is that if someone kicks out the powercord while your user has this form open, and the record half filled out, and some gibberish in the current field because it hasn't yet been evaluated to check if it is valid, nothing bad will happen to your tables. In fact, nothing will happen to your tables at all, because kicking out the power cord doesn't call the code you've written to save the record.

OK, so it got a little longer than I thought it would be, but there's a short take on unbound forms.

Hope it helps.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access databases since 1995.
 
Since I know I cannot prevent CTRL ALT DEL from closing the form is there any way I can diplay a message when the CTRL ALT DEL is hit that the record is only partially filled in and the database is going to close?
 
Laruajo,

Yes, if you get into windows programming. Again, that's happening at the operating system level, not the Access level. There's no way to trap for that.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access databases since 1995.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top