Wrox Programmer Forums
|
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
 
Old August 22nd, 2003, 04:46 AM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA Forms (Access 97)

Hi,

Does anyone now how to check if a form is open and close it from another form?;)

Tim
__________________
Tim
 
Old August 22nd, 2003, 07:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old September 5th, 2003, 10:34 AM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old September 5th, 2003, 11:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old September 7th, 2003, 03:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old September 7th, 2003, 05:37 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect / Unprotect Excel 97 - VBA Code - jlpazv Excel VBA 2 November 30th, 2007 10:54 AM
Access 97 VBA: Change file extensions yackyack75 Access VBA 2 December 1st, 2005 02:23 PM
Access 97 Benwaa Access VBA 0 January 28th, 2004 02:37 PM
Migrating from access 97 to access 2000 Khalifeh Access 12 October 2nd, 2003 02:54 PM
Listboxes In Access 97 timmaher Access VBA 6 June 9th, 2003 03:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.