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

Close Access Form on Mouse Click...?

Status
Not open for further replies.

avarga82

Programmer
May 19, 2003
62
US
Help! I am opening a form modally, and need to close the form if the user clicks anywhere BUT on the form. So, if Form1 is open and the user clicks on Form2 (which he really can't, because Form1 is open modally), I want Form1 to close. Is there anyway to do accomplish this? Any help would be appreciated. Thanks!

 
In my opinion you can't do this whilst Form 1 is Modal - by virtue of it being set to Modal - the user cannot access Form 2.
If you want to close Form 1 when the user clicks on Form 2 then use the OnGotFocus of the form to DoCmd.Close or Forms!Form1.visible = False

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
Hmmm, maybe something with the Windows API functions? I've not delved into them, but unless you change your Form from Modal, I don't see any possibility of getting the desired results, unless it can be done through the Windows API. I have no knowledge or experience there, but have seen it mentioned many times in posts, and it seems quite interesting.

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
You can try using
DoCmd.Close acForm, "FormName",acSaveYes or NO.
You can put this in the OnClick event of the form.

There is something to keep in mind ..... if the user closes the form what is to happen with any data entered or edits made???
Also, you can eliminate the Tool bar and hide the task bar. Not sure where else someone might click.

What exactly is the problem you are having?? From my perspective, I feel a great deal of thought shoud be given as to WHY???


An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
The logic definitely would need to be considered here, as mentioned by mph1. For example, if you want your forms to be modal, then what would be wrong with having a button on one form something like "Go To Form 2" which would run all the code to close your Form 1 and open Form 2?

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
I didn't explain my need for this. I have a continuous form, and it's not an updatable recordset. So, after much exhaustion and API coding, I rigged it so when you click on a field, another form (that looks like a textbox) is opened directly above that field, so you can "edit" the data. When the form is closed, the field is updated to the value on the pop-up form. Now, if the popup form is OPEN, I want the user to be able to click on another record (which is really the original form) and close the popup form. Also, it can't be an On Click event because I'm not actually clicking ON the form. Any ideas...?
 
When you open the popup form set the focus to the textbox within the form - then set the OnLostFocus event to close the popup and (just to be sure) use the onGotFocus of the base form to close the popup form as well.

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top