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

Disabling the close button on access db

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hello,

I wanted to be able to disable the close button in the access database and for the user to only use the main form to close the application.

How can I do this?

Many thanks,

Integrity
 
In the main form you need some kind of code like this

Code:
Dim blnClose As Boolean

Private Sub CmdClose_Click()
  blnClose = True
  DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Unload(Cancel As Integer)
 If Not blnClose Then DoCmd.CancelEvent
End Sub

This would mean that the main form always need to be open. So if you want to hide the main form make it invisible.
 
Hi MajP,

Thank you for your reply. It works really great. I changed the following to application.quit. But it works great.
Code:
DoCmd.Close acForm, Me.Name

Juts another question,
How can I stop user from minimizing the database. They do this and leave it open. Now that they are not able to close the db from the close, I now want to stop them minimizing it.

Many thanks,

Integrity
 
You may consider to regulary call the following:
DoCmd.Maximize

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
integritycare said:
How can I stop user from minimizing the database.

With training? Some times I think we spend 80% of our time programming around issues that could be avoided with higher user expectations. It would be great if we could take that 80% to provide better solutions and functionality.

Duane
Hook'D on Access
MS Access MVP
 
Hi dhookom,

We provide monthly training and updating skills. All co ordinators function with 3 monitors each,so there is no need for users to minimise the database. but they just don't listen.
Cant replace them cause here in Australia we are governed by what we are able to do in replacing staff.

But is does cause major headaches for us. But I agree with you entirely.

Integrity
 
I posted the same question a while back and got this suggestion - it may have been from dhookom (not sure):

Short of a baseball bat to the knees (you only have to do it once if you do it in front of the other users) there are a few things you can do.

If you put your code in the 'On Close' event it will run even if they 'X' out. If it is in the 'On Click' event of a button it won't. I would do this even if you hide the buttons.

Yes, you can hide those buttons -- set the Form Property 'Control Box' to 'No'.
 
I know of no easy way to do it without using windows API. I do not think there is any way using vba to determine if the application window is minimized, and there is no application level event to trap a minimization event. So as PHV suggested, I think you are stuck with writing a continuous loop on your main form with do events to continually tell the application to maximize just in case it is minimized. I do not think that is a good alternative. What is the problem with minimizing it? What problems does it cause. How is your database set up for front end and back end? Where is the back end located? Do all users have there own front end? There is plenty of code to determine who is logged in. You could write a small app to send an email to someone if they have been logged in for X hours.
 
Hi guys,
Many thanks for your replies.

But dhookom is so correct. I do run around doing things that need not be done due to the (stupidity of employees!) and I mean that in a nice way. I can be better employed looking after the necessary things that are urgent. Over the weekend I thought of a better solution. On the server I have kicked all staff of at 5.10pm. So even if they leave the db open it can not be accessed. As we share offices we had a security breach, that what prompted me to post this query. But the comments posted by dhookam just set me thinking a lot more. Thanks Duane for that.
But guys many thanks for your input. To a technical user it is so valuable.

Regards,

Integrity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top