 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 22nd, 2003, 04:46 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
VBA Forms (Access 97)
Hi,
Does anyone now how to check if a form is open and close it from another form?;)
Tim
__________________
Tim
|
|

August 22nd, 2003, 07:16 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by timmaher
Does anyone now how to check if a form is open and close it from another form?;)
|
Code:
DoCmd.Close acForm, "{name of desired form}", acSaveYes
The acSaveYes saves any data before closing the form.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

September 5th, 2003, 10:34 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am having a problem using DoCmd.Close
I have a form that checks to see if the data being entered is being entered into the correct form.
If the data being entered into Form1 is supposed to be entered into Form2, I want to close Form1 and open Form2.
I'm using
DoCmd.OpenForm "Form2"
in the module of Form1 to open Form2.
Then in the Open event of the Form2 I'm using
DoCmd.Close acForm, "Form1", acSaveNo
to try and close Form1.
My problem is, I can get Form2 to open, but I can't get Form1 to close.
Any suggestions?
|
|

September 5th, 2003, 11:15 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by jrichad
My problem is, I can get Form2 to open, but I can't get Form1 to close.
|
See if the order in which you do it is important. Try closing Form1 before opening Form2. Some weird system stuff may be happening because Form1 may be open but doesn't have the focus to close. Sounds funny, but you know Access...
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

September 7th, 2003, 03:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I would suggest is just put both actions in Form1's event, i.e. Open Form1, then close Form2 all from the same procedure, such as:
Sub OpenOtherForm
DoCmd.OpenForm "Form2"
DoCmd.Close acForm, "Form1", acSaveNo
End Sub
Which would be in Form1's module
Steven
I am a loud man with a very large hat. This means I am in charge
|
|

September 7th, 2003, 05:37 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You stated that if the data was supposed to be in Form2 and they were entering it in Form1, then Form1 is supposed to close and Form2 open. Are you transferring the data values that they may have already entered in Form1 to Form2? If so, then you probably need to tell Form1 to open Form2, then in Form2 onActivate event tell Form1 achidden, then when you close Form2, it take you back to Form1 acNormal (or close both).
Regards,
Beth M
|
|
 |