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

Close one Form and OPen another

Status
Not open for further replies.

DanAuber

IS-IT--Management
Apr 28, 2000
255
FR
Hi,

I have a button on Form1 - when it is clicked I want the following to happen:

i) Open Form2
ii) Close Form1

(or the other way round)

Can anyone help me with this - I have tried the below, but Form1 stays open grrrr...


Private Sub Command5_Click()
DoCmd.OpenForm "Form2"
DoCmd.Close acform, "Form1",acsaveno


End Sub



 
How are ya DanAuber . . .

Chances are the [blue]Modal[/blue] property of Form2 is set to yes. When a form opens modal, code in the calling form stops running until the called form closes.

Set the Modal property to Yes, or reverse the two lines . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
If Form1 is to be used again, you could make Form1 invisible, Form1.Visible = False, and then have the DoCmd.OpenForm "Form2" line. Then say when you have finished with Form2, and you then go back to Form1, you would make a command button and put DoCmd.Close, and then Form1.Visible = True.

Just an idea,

Andrew
 
Woops!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Woops! . . .

Should've been: [blue]Set the Modal property to [purple]No[/purple], or reverse the two lines . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Have you tried using a macro?

Design a macro
In the macro design, Set the first line to OpenForm then the second line to closeform. Set the properties (which forms) for each one.

Then when adding the command butto, set the properties to run macro.

This is what I have found to be the easiest instead of trying to wrangle code.
 
This is very easy if you are doing this from your Open button for the new form click event. Place something like this in your event code...

Dim formname as string

formname = me.name
docmd.open "form2"
docmd.close acform, formname

That should do it.

Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top