views:

117

answers:

1

The below code is the close routine of an Access App our BA wrote. When executed it is not only closing the Access App but my C# winform app as well, on the same computer. The Access app is named DME Referral and my winform app main process runs in the Task Manager as MATRIX.exe.(Yes I am programming the MATRIX...never allow a group of Social Workers and Nurses to name your program!)

I do not do much with Access(VBA) programming so I am hoping someone here can help.

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

Call ToggleVisible

DoCmd.Quit

Exit_cmdClose_Click:
    Exit Sub

Err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click

End Sub

Private Sub ToggleVisible()
    Me.txtLastNameCrit.Visible = False
    Me.txtFirstNameCrit.Visible = False
    Me.cmdSearch.Visible = False

    Me.cmbCoor.Visible = False
    Me.cmdSearchByCoor.Visible = False

    Me.txtStartDate.Visible = False
    Me.txtEndDate.Visible = False
    Me.cmdDMEReport1.Visible = False       
End Sub
+2  A: 

DoCmd.Quit should be just closing the MS Access portion; it's pretty standard.

I'm willing to be that one of two things are happening.
1) Focus has switched over to the C# winform app, and it's catching a signal to close. In this case, we can explicitly set the focus back to the MS Access form. You can do that with Me.SetFocus.
Or
2) The C# winform app. is being launched from withing MS Access; and when the parent application is closed, the child is as well. In this case we may have to change the way the C# winform app. is launched. Does it close down as well when you manually close MS Access (click the 'X' on the top right corner)?

CodeSlave