access:close one form open another and vice versa

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.
topUKlawyerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
omgangConnect With a Mentor IT ManagerCommented:
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
 
topUKlawyerAuthor Commented:
when i say linked to each other i mean that one button opens the other form and vice versa.
0
 
omgangIT ManagerCommented:
Actually, I am mistaken.  No error even if the other form isn't open.
OM Gang
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
topUKlawyerAuthor Commented:
Thanks

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

how do i do that please?

0
 
omgangIT ManagerCommented:
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
 
omgangConnect With a Mentor IT ManagerCommented:
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
 
topUKlawyerAuthor Commented:
sounds good, thanks

will test tomorrow and award points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.