Acess 2010 Form Closes When Another Form Closes In Desgn Mode

Hi Experts,
I have a Form (A) that has a button that opens Form B (not a SubForm) and populates fields on Form B from Form A via the Form Load Event.  There is no direct linkage between the two Forms and they use different Tables..

If I change Form B into Design Mode and then back to View Mode, Form A is closed in the background without any notification.

If I change Form B back to View Mode an Error is produced advising that Form B can't find Form A.

If I simply close Form B from View Mode without having gone to Design Mode, Form B closes and Form A is displayed without any problem.  i.e.  It hasn't been closed.

Is this a Microsoft Bug or am I doing something incorrect?

This would not be easy for me to put into a version to provide you for analysis and the original application is about 100 Meg.

Since this only happens when using Design Mode I can live with it.

Bob C.
Bob CollisonSystem ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you have any code and/or Macros in form B that reference or control Form A?  I'd suggest checking the Open, Load, Current and Close events of form B.

Also check the code behind the button on Form A which opens Form B.  If form B is opened using "acDialog" for the windows mode, then closing, hiding, and I believe changing form B to design view will all trigger any code after the OpenForm command in the click event of the command button to resume execution.
Bob CollisonSystem ArchitectAuthor Commented:
Hi Expert,
The functionality of these forms is as follows.
Form A contains Event Registration data including such things as a Registration Fee, Payment, etc.  Since Form A is active when Form B is opened the data in Form A may not have been saved to its associated Event Registration Table.

Form B contains Event Registration Invoice data in the Event Invoice Table based in large part on the data in Form A.  It also has various functions to print the Invoice, Email an Invoice, etc.

Regarding your questions.
I am attaching a text file containing the code related to your questions.  To summarize.
- Form A doesn't use the acDialog to call Form B.
- There is code referencing Form A in the Form B Load Event.  see attached.
- There is no code in the Form B Open  or Close Form Events referencing Form A or in any other Form B Events.

One solution would be to force the saving of the data in Form A when the button is clicked to Open Form B and then looking the Event Registration Table data up in Form B.  This would eliminate the data references in the Form B Load Event to the Form A Fields.  I assume that this would correct the problem.

If it is viable and I were to go with the solution I proposed above, how do I force the saving of the Form A data to its associated Table when the Button is clicked to open Form B?

Is there another better solution?

Bob C.
Gustav BrockCIOCommented:
You could do that this way:
Private Sub BtnF41410_CreateInvoice_Click()

    Dim stDocName_F41410 As String
    Dim stLinkCriteria_F41410 As String

    On Error GoTo Err_BtnF41410_CreateInvoice_Click

    ' Save current record if not already saved.
    If Me.Dirty = True Then
        Me.Dirty = False
    End If

    stLinkCriteria_F41410 = "[PERIOD_EVENT_GRP_REG_KEY]=" & "'" & Me![PERIOD_EVENT_GRP_REG_KEY] & "'"
    stDocName_F41410 = "F-41-410 - Event Group Invoice Form"
    DoCmd.OpenForm stDocName_F41410, , , stLinkCriteria_F41410


Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob CollisonSystem ArchitectAuthor Commented:
Hi Experts,
I appreciate the comment by mbizup however I adopted the solution supplied by gustav.
Thanks for your expertise.
Bob C.
Gustav BrockCIOCommented:
You are welcome!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.