Solved

NEXT and BACK Button

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

738 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