Solved

NEXT and BACK Button

Posted on 2011-02-28
5
516 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 119

Accepted Solution

by:
Rey Obrero earned 250 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 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 125 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 125 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now