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

disable to close button

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
hello all,

how can I do this :

When I click on the x in the top right corner, if the user is currently adding a record, then undo the add and close.

at the moment I get an unfriendly message saying : you cannot add or change a record because a related record is required in tblitems.


thank you in advance.
also I hope that makes sense.
: )
cheers.
 
The message you're getting has nothing to do with clicking the X in the top right - it is because you are attempting to insert a record on the "many" side of a relationship, and there is no foreign key value that ties it to the "one" side - for example, you have a table of DEPARTMENTS and a table of DIVISIONS. Each DIVISION can have MANY Departments. You are trying to add a DEPARTMENT record, and you don't have a valu for the DIVISION it belongs to. This is called referential integrity, is generally a good thing, and you need to assign a value to the DIVISION code at the DEPARTMENT level so you can add it. It's kinda like creating a child without giving it a parent. Can't be done.

"Remember, you're unique - just like everyone else"
You're invited to visit another free Access forum:
or my site,
 
I can get rid of this message by allowing NULL's but I don't want to do that., how can I get rid of this message if nothing is selected ?
 
Hi Welshone,


You can't add in each Form a Controls Yes/No you can't call ctlCanCloseForm

On Event Open of each Form you need to set the control to False

Private Sub Form_Open(Cancel As Integer)
Me!ctlCanCloseForm = False
End Sub

On Event Form_Unload Check if this Box Is Set To Yes

Private Form_Unload(Cancel As Integer)

If Me!ctlCanCloseForm = False Then Cancel = True
'Or
Cancel = Not Me!ctlCanCloseForm

End Sub

Finally On Each Button Close you need to set the control at True before closing the current form or Other One.

Private Sub cmdClose_Click()

Me!ctlCanCloseForm = True
DoCmd.Close acForm, Me.Form.Name, acSaveNo

End Sub

 
cheers,
but thats not what I need to do.
I do have a close button on my form , which works if clicked, however, a user can still click on the x in the top right hand corner to quit the application.
What I need is if a user clicks on that x, then either nothing happens or a message appears tellingthe user to use the close button to quit.

is that possible ?
 
Why not eliminate the problem by disabling the X option and force the user to use the CLOSE button you provided.. Simply go to the FORM property (not the control property) and set the FORM Close Button property to NO. This way the user will use your CLOSE button and it's code.

You might consider setting the MinMaxButton option to NO as well.

Good luck.
 
but thats for the form, not the aplication.

you know when you open an mdb file, it uses access.
I can disable the close button for each form, that not a problem, I need to disale to actual application ( access ) close button.

When you open a form with the close button enabled can you see 2 x's in the top right ?
 
Hi!

Do what epoirier has suggested and you will find that as long as any form is open the application will not close. All you need to do is add a message box which will provide the user with the message you want them to see. If you have a main form (like a switchboard) that stays open all of the time, you can put the code in that form only and supply a Close Access button that will force the user to click that button to close the application.

hth
Jeff Bridgham
bridgham@purdue.edu
 
what is ctlCanCloseForm ?
is this something I need to create ?

thank you
 
ACC2000: How to Disable the Close Button (X) on the Access Application Window (Q245746)

, search the knowledge base for the article Q245746. This article explains how to do it and includes the code. Very lengthy though.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top