Solved

NEXT and BACK Button

Posted on 2011-02-28
5
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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