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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KISS way to force users to click a command button (faq702-2071)

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
US
I have a problem where users may "X" out of access by clicking the X on Access itself (not on the form(s) because i have them turned off on the forms properties). When the users do this they circumvent ceratin operations in the close event for the form(s).

I tried the technique propounded in faq702-2071 and get the following result ~

When the X box for Access is clicked, the application does not terminate and the active form remains the current window, however, it is impossible to get any focus back on the form, i.e. you cannot exit the form, you cannot do anything whatsoever, the only option is to ctrl alt delete and kill access.

Any suggestions for getting around this problem ??

thanks
 
I have not used the feature, but I know there is a 'close' button on a form that can be set to yes or no. The default is 'yes.' Just set it to 'no.' How about that for KISS?????

Rollie
 
I have used that technique on a couple different computers in stand-a-lone applications. If you use one of the form event properties that passes a cancel parameter and you set cancel to true, the form retains focus. I'm not sure what may be causing you a problem.

My email address is in my profile. If you send me a message with the code you are attempting, I will be happy to take a look at it.

Good Luck!

SBendBuckeye
 
Just a comment to say that I have used the code in the FAQ mentioned in this post, and it works fine for me.

I have a system which I developed and then distributed it to the users and it works fine.

I have a main menu which is alway open like a nav bar on the left hand side of the screen.

The users use this to access all areas of the application.

The code is used from the exit button on the menu ( nav bar ) which is always on top on the left hand side.

Only when this button is pressed then the allow close is true and the program exits, any other method will not allow them to close access, but still allows them to continue working with it.

Idd.
 
OK, here is drill, get to work! Once you put this in, when the user clicks the corner close buttons(both the Start Form or Access), it will goto the Start Form (the form that you have the close or exit button)and clicks the exit button for the user to end the session and exit mercifully.

1. On your Start Form property, make sure to set PopUp to No and Modal to Yes.

2. create a new module (name it whatever you like), and just declare a value

Public fOKToClose As Boolean ‘I call it fOKToClose

3. Go back to the Start Form, in your Exit/Close button On Click event module, before the Docmd.Close(or whatever codes you have to shut down Access)and after whatever codes you want to do before exit, set fOKToClose to True, so it can close and exit Access.

fOKToClose = True 'Set to true to allow closing the database
DoCmd.Close
DoCmd.RunCommand acCmdExit

4. On the Start Form’s On Load event put the following codes.

fOKToClose = False 'Set to false to prevent user closing out the database without using the proper button.

5. on the Start Form’s On Unload event, put the following codes (this will allow user to close Access with the corner X close button, but it will automatically click the exit/close button on the Start Form for the user, thus the other codes that you have in the close/exit button will triggered before exiting.)

Cancel = Not fOKToClose

If fOKToClose = Not True Then
DoCmd.OpenForm "StartFormName"
Me.ExitButtonName.SetFocus
SendKeys "{enter}"
Else
Exit Sub
End If

If you want to tease the users by sending a message instead of closing it for them, use the option below in your On Unload event of the Start Form.

Cancel = Not fOKToClose

If fOKToClose = Not True Then
MsgBox “Wrong button, try again!”
Else
Exit Sub
End If

Done Deal!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top