If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Closing Forms.
Help please! How do I get a form to close on exit. I have used a switchbord
form where I navigate to other forms in the data base, what is the best way to close a form automatically I have finished reviewing it and I return back to the switchboard again? I have read some of the threads but still unsure where the code is written to. Cel504, many thanks |
#2
|
|||
|
|||
Closing Forms.
One option is to open your forms in modal modal so user have to close the
form themselves before being able to go elsewhere. Another option would be to use the form's got focus event to close all open forms. Something like: Dim DbF As Form Dim DbO As Object Set DbO = Application.Forms 'Collection of all the open forms For Each DbF In DbO 'Loop all the forms If DbF.Name "SwitchboardFormName" Then DoCmd.Close acForm, DbF.Name End If Next DbF Set DbO = Nothing -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post using the vote buttons if it was helpful. "CEL504" wrote: Help please! How do I get a form to close on exit. I have used a switchbord form where I navigate to other forms in the data base, what is the best way to close a form automatically I have finished reviewing it and I return back to the switchboard again? I have read some of the threads but still unsure where the code is written to. Cel504, many thanks |
#3
|
|||
|
|||
Closing Forms.
CEL,
In either the Form's Deactivate or LostFocus event paste this code, adjusting for the Form name: Private Sub Form_LostFocus() Exit Sub DoCmd.Close acForm, "Form4" End Sub CEL, The best way is to put a Close button on the form with code like this in the CLick event: Private Sub btnClose_Click() DoCmd.Close acForm, "Form4" DoCmd.OpenForm "Switchboard" 'If Switchboard is the name of the form to go to End Sub This will bring up the switchboard whether or not it is open. God Bless, Mark A. Sam "CEL504" wrote in message ... Help please! How do I get a form to close on exit. I have used a switchbord form where I navigate to other forms in the data base, what is the best way to close a form automatically I have finished reviewing it and I return back to the switchboard again? I have read some of the threads but still unsure where the code is written to. Cel504, many thanks |
#4
|
|||
|
|||
Closing Forms.
I don't see how it will work to have Exit Sub before the code to close the
form. I think the command button code is the way to go, since the user presumably has to click a button (or something) to return to the switchboard. Also, it should be possible to use Me.Name instead of the form name: DoCmd.Close acForm, Me.Name It doesn't work any differently than if the form is named, but I find it more convenient. It may not be necessary to open the switchboard form, as it may not have been closed when Form4 was opened. Mark A. Sam wrote: CEL, In either the Form's Deactivate or LostFocus event paste this code, adjusting for the Form name: Private Sub Form_LostFocus() Exit Sub DoCmd.Close acForm, "Form4" End Sub CEL, The best way is to put a Close button on the form with code like this in the CLick event: Private Sub btnClose_Click() DoCmd.Close acForm, "Form4" DoCmd.OpenForm "Switchboard" 'If Switchboard is the name of the form to go to End Sub This will bring up the switchboard whether or not it is open. God Bless, Mark A. Sam Help please! How do I get a form to close on exit. I have used a switchbord [quoted text clipped - 8 lines] Cel504, many thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#5
|
|||
|
|||
Closing Forms.
It doesn't. I was just playing around and thought I had that working. I
didn't mean to post that portion. If you scroll down you will see that I suggested a close button. Sorry for the confusion. "BruceM via AccessMonster.com" u54429@uwe wrote in message news:a321bedacfd39@uwe... I don't see how it will work to have Exit Sub before the code to close the form. I think the command button code is the way to go, since the user presumably has to click a button (or something) to return to the switchboard. Also, it should be possible to use Me.Name instead of the form name: DoCmd.Close acForm, Me.Name It doesn't work any differently than if the form is named, but I find it more convenient. It may not be necessary to open the switchboard form, as it may not have been closed when Form4 was opened. Mark A. Sam wrote: CEL, In either the Form's Deactivate or LostFocus event paste this code, adjusting for the Form name: Private Sub Form_LostFocus() Exit Sub DoCmd.Close acForm, "Form4" End Sub CEL, The best way is to put a Close button on the form with code like this in the CLick event: Private Sub btnClose_Click() DoCmd.Close acForm, "Form4" DoCmd.OpenForm "Switchboard" 'If Switchboard is the name of the form to go to End Sub This will bring up the switchboard whether or not it is open. God Bless, Mark A. Sam Help please! How do I get a form to close on exit. I have used a switchbord [quoted text clipped - 8 lines] Cel504, many thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#6
|
|||
|
|||
Closing Forms.
Disregard my first post. I was playing around and thought I had the
procedure working, but wasn't thinking properly. I left that part in by mistake. So here is my correction. The best way is to put a Close button on the form with code like this in the CLick event: Private Sub btnClose_Click() DoCmd.Close acForm, "Form4" DoCmd.OpenForm "Switchboard" 'If Switchboard is the name of the form to go to End Sub This will bring up the switchboard whether or not it is open. God Bless, Mark A. Sam "CEL504" wrote in message ... Help please! How do I get a form to close on exit. I have used a switchbord form where I navigate to other forms in the data base, what is the best way to close a form automatically I have finished reviewing it and I return back to the switchboard again? I have read some of the threads but still unsure where the code is written to. Cel504, many thanks |
Thread Tools | |
Display Modes | |
|
|