Solved

access:close one form open another and vice versa

Posted on 2011-03-02
7
348 Views
Last Modified: 2012-08-13
I have two forms linked to each other by command buttons.

I want to make sure that when one form opens the other closes and vice versa.

The reason I want to do this is to make sure that data is saved/updated when the other form is gone into. They have data common to one table.

Is there an easy way to achieve what I want.
0
Comment
Question by:topUKlawyer
[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
  • 4
  • 3
7 Comments
 

Author Comment

by:topUKlawyer
ID: 35019920
when i say linked to each other i mean that one button opens the other form and vice versa.
0
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 35020445
Try putting something like this in the Form_Open event for each form


Dim strFormName As String
strFormName = "OtherFormName"
DoCmd.Close acForm, strFormName

If the other form isn't actually open the DoCmd.Close command will throw and error but you can trap that in an error handler.  Let me get back to you.
OM Gang
0
 
LVL 28

Expert Comment

by:omgang
ID: 35020483
Actually, I am mistaken.  No error even if the other form isn't open.
OM Gang
0
Industry Leaders: 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!

 

Author Comment

by:topUKlawyer
ID: 35020496
Thanks

i would also like the dbase to open with one of those forms open.

how do i do that please?

0
 
LVL 28

Expert Comment

by:omgang
ID: 35020533
More than one way to accomplish that.  You can specify a startup form for the database; you can create a macro named Autoexec that will be executed each time the database opens - in the macro you have an OpenForm command to oepn the desired form.

What version of Access?
OM Gang
0
 
LVL 28

Assisted Solution

by:omgang
omgang earned 500 total points
ID: 35020652
In Access 2003 and earlier:  from the Tools menu choose Startup.  In the combo box for Display Form/Page:  select the form you want to be displayed at startup

In Access 2007:  select the Access orb/globe/thing-a-majob and choose Access Options.  Select Current Database in the left pane.  In the right pane, in the Application Options section, you'll see a combo box titled Diaply Form: where you can select the form you want displayed at startup.

OM Gang
0
 

Author Comment

by:topUKlawyer
ID: 35020942
sounds good, thanks

will test tomorrow and award points
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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.
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 …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

691 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