?
Solved

access:close one form open another and vice versa

Posted on 2011-03-02
7
Medium Priority
?
351 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
  • 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 2000 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

755 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