Prevent people from closing access

P

pokdbz

I have an access program in which information is gathered at the end of an
interview the person should click a button to complete the interview this
will do a much of calculations. The problem that I am having is sometimes
the person thinks they are done so they click the X at the top right of
access and not the button. So when I go to check the data from the interview
it is not there because they didn't click the button.

How do I prevent someone from using the X to close out the program. I only
want it to close out with a button on the form.
Thanks
 
J

Jeff Conrad

Hi,

I use these techniques. They work great.
Take your pick based on version.

ACC: How to Disable the Close Button (X) on the Access
Application Window (95/97)
http://support.microsoft.com/?id=258049

ACC2000: How to Disable the Close Button (X) on the Access
Application Window
http://support.microsoft.com/?id=245746

ACC2002: How to Disable the Close Button (X) on the Access
Application Window and the Exit Command on the File Menu
http://support.microsoft.com/?id=300688

Alternatively, take a look here:

http://www.mvps.org/access/general/gen0005.htm

Hope that helps,
 
S

Sam Kuo

Please excuse me for tagging to this discussion.
Is there a way that the Close Button (X) on the "database window" could also
be disabled?
 
J

Jeff Conrad

Sam Kuo said:
Please excuse me for tagging to this discussion.
Is there a way that the Close Button (X) on the "database window" could also
be disabled?

Not to my knowledge Sam.

I prefer to simply hide the Database Window from the users by going to
Tools | Startup and un-checking the option that says:
Display Database Window.

The only other option I am aware of is to create your own form that
"emulates" the Database Window. The Access Developer's Handbook
has a sample form and code to do this, but you need to purchase the book.
(A good investment in my opinion.)

Personally I think it is too risky to give users access to the database window.
Who knows what they could screw up?!
:)
 
M

Mike Labosh

Please excuse me for tagging to this discussion.
Not to my knowledge Sam.

The Database Window has a title-text and a hWnd.

I forget the name of the API function, but there is one that lets you get
the hWnd of a window by passing its title-text.

Then you call the SetWindowLong() API function passing a flag for the [x]
button and a zero, to turn it off. I recall seeing that in Dan Appleman's
"Visual Basic Programmer's Guide to the WIN32 API"

However, in the wake of buying a house and moving, I can't find that dang
book anywhere, so I can't supply a page # or code snip. :(
 
S

Sam Kuo

Thanks to you both! I will have a look at the books you recommend sometime :)

Mike Labosh said:
Not to my knowledge Sam.

The Database Window has a title-text and a hWnd.

I forget the name of the API function, but there is one that lets you get
the hWnd of a window by passing its title-text.

Then you call the SetWindowLong() API function passing a flag for the [x]
button and a zero, to turn it off. I recall seeing that in Dan Appleman's
"Visual Basic Programmer's Guide to the WIN32 API"

However, in the wake of buying a house and moving, I can't find that dang
book anywhere, so I can't supply a page # or code snip. :(

--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."
 
J

Jeff Conrad

Interesting, I was not aware of that capability Mike.

--
Jeff Conrad
Access Junkie
Bend, Oregon

Mike Labosh said:
Not to my knowledge Sam.

The Database Window has a title-text and a hWnd.

I forget the name of the API function, but there is one that lets you get
the hWnd of a window by passing its title-text.

Then you call the SetWindowLong() API function passing a flag for the [x]
button and a zero, to turn it off. I recall seeing that in Dan Appleman's
"Visual Basic Programmer's Guide to the WIN32 API"

However, in the wake of buying a house and moving, I can't find that dang
book anywhere, so I can't supply a page # or code snip. :(

--
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will."
 
M

Mike Labosh

Interesting, I was not aware of that capability Mike.

In 1995, I had to have Access 2.0 do an export batch of lots of .txt files,
then ZIP them, then delete them.

That get-hWnd-from-title-text function was extra handy in waiting for the
command prompt pkzip window handle to disappear instead of deleteing the
text files prematurely. LOL! the first couple of tests of that code were
REALLY messy.

Having been working 24x7 in .NET for the last three years, I'm a bit rusty
on some of my old favorite API functions.
 
Top