CODE
Dim strForm As String = "frmEntry"
Dim oForm As Access.Form
Dim oAccess As New Access.Application()
oAccess.OpenCurrentDatabase("c:\database\mydb.mdb", false) ' Opens database
If Not oAccess.Visible then oAccess.Visible = True ' Ensure that it is visible
' Make a connection to the form in the DB
oAccess.DoCmd.SelectObject(Access.AcObjectType.acForm, strForm, True)
oAccess.DoCmd.OpenForm(strForm, Access.AcFormView.acNormal)
oForm = oAccess.Forms(strForm)
oForm.Controls.Item("txtTicketNumber").Text = Me.txtTicket.Text ' Perform data-entry into the DB form
' [... continue for all other data fields. When done call ProcessTicket to update DB]
oForm.ProcessTicket() ' ProcessTicket is a Public sub
However the problem with this is that the way that I am automating the data-entry into the Access form opens a new instance of the Access DB. What I would like to do is be able to use an instance of the DB that is already open (or perhaps check to see if there is an instance open, and to use it if so). Eventually I'd like to be able to have a button on this form in Access that when pushed will run the VB.Net app. and automate the data-entry back into that form.
I was thinking of using GetObject method, but according to the MS site, that method will not allow one to control the Access application, and so they recommend using the OpenCurrentDatabase function instead. Is this the problem; is there a different function I can use to gain control of the already running Access instance? Or is my problem with initializing oAccess with a New Access.Application? Or am I going about this automation completely wrong?