Full Version: close front form...
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
kbrewster
Say I have 3 forms open...I want to close the form that is in the front...or the one that has focus.

I want it to be used on any form, so I don't want the code to include the form name.

Thanks!
BrianS
I think you can refer to the active form with
CODE
Screen.ActiveForm

CODE
Docmd.Close acForm, Screen.ActiveForm

The only trick is going to be where you call this code from. I would create a Public function in a standard code module and call it from anywhere that is neccessary.
kbrewster
I am using it on a menu bar...
kbrewster
I want a form that has a tree view on it...already created that. The treeview has a main category "Patient Information", then sub categories "Demographics", "Test Results".

What I would like to happen is to have the SAME form change to whatever the users chooses. So if the user is in "frmPatientInformation" and has chosen "Demographics" from the tree view the patients demographics would show up...then they click "Test Results" and I want the test results for the patient to show up...BUT without opening new forms on top....does this make any sense?
argeedblu
In the on-click event of your command button you can start with the statement me.visible = false. If there is a chance the user will go back to the form later, it is better to leave it open but not visible. Then when the user clicks a button on another form to return to the first one, just specify that it should be viisble again. That saves loading time between forms.

Glenn
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.