Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NEXT and BACK Button

Posted on 2011-02-28
5
Medium Priority
?
528 Views
Last Modified: 2012-05-11
I have two forms:
Form1 and Form2

I need a SIMPLE example of code that will close Form1 and open Form2 and vice-versa.

Please see attached sample data base.
Open-Close1.accdb
0
Comment
Question by:cssc1
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 35003459
to open form2 from form1 and close form1


from form1 call this codes in the click event of a button
docmd.close acform, me.name
docmd.openform "form2"


from form2 call this codes in the click event of a button
docmd.close acform, me.name
docmd.openform "form1"
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 35003560
or this

from form1 call this codes in the click event of a button

docmd.openform "form2"
docmd.close acform, me.name

from form2 call this codes in the click event of a button

docmd.openform "form1"
docmd.close acform, me.name
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 35004832
Depending on what you are doing I find it a lot more efficient is you are switch between the two for very often is to hide the form ( .visible = false) and not close the form. This avoid the loading process. I generally see significant improvements in speed.

Example:

Form1 - command button's On Click event:

Me.Visible = False
DoCmd.OpenForm "form2"

Form2 - command button's On Click event:

Me.Visible = False
DoCmd.OpenForm "form1"



The trick is her is that use the DoCmd.OpenForm and if the form is not loaded it will be loaded. If it is loaded and not visible it will make it visible.


Another option is to use a tab control to crate a wizard style form using a tab control.

See: Wizard Form template





0
 
LVL 10

Assisted Solution

by:t_hungate
t_hungate earned 500 total points
ID: 35009343
If you use a visibility options as TheHiTechCoach is suggesting.  Just make sure that you close those forms when you are done with them or they will remain hidden and take up memory.

Also, on older systems depending on the size of your forms and the functions attached to them, this can slow the overall performance of your DB.  Not a problem on any newer systems.

TLH
0
 

Author Closing Comment

by:cssc1
ID: 35142956
Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question