This may be a simple fix but I'm not seeing it. My VB application calls MS Access by the click of a form button. Simple enough but here goes the problem:
As soon as my VB code opens the Access DB/Form, control returns to the next executable line in my VB code. The next executable set of code closes the DB and quits Access. In other words, MS Access loads and quits in a blink of an eye.
Is there a way to suspend the VB code from executing until control returns from MS Access? Another option is to check, within VB, if the Access DB is currently open (vb code example would be great). Either way would help.
Thanks.
Below is my VB code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CallBRS.Click
Dim oAccess As Object 'Access.Application
' Start a new instance of Access for Automation:
oAccess = CreateObject("Access.Application")
' Open a database in exclusive mode:
oAccess.OpenCurrentDatabase("C:\TotalScript BRS\BRS\BRS.mdb")
oAccess.DoCmd.OpenForm("BRS Account", Access.AcFormView.acNormal)
‘????? Problem is here ??????
'oAccess.CloseCurrentDatabase()
'oAccess = Nothing
'oAccess.Quit(True)
Exit Sub
End Sub