Solved

NEXT and BACK Button

Posted on 2011-02-28
5
519 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 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 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