Call Access form procedure from Excel form
Call Access form procedure from Excel form
(OP)
I'm having a bit of a problem calling an procedure on a
Microsoft Access Form from an Excel Form. I've created the
Access object, opened the database containing the form,
displayed the form, autofilled some textboxes, but I can't seem
to get the correct syntax to call one of the access form's
procedures. This is what I have so far:
I have an Access form called InputData
It has a textbox called txtData
From within an Excel form I have this code:
Dim appAccess As Object 'Microsoft Access database object
'Create an instance of Microsoft Access
Set appAccess = CreateObject("Access.Application")
With appAccess
'Open the database "ABC.mdb"
.OpenCurrentDatabase "C:\My Documents\ABC.mdb"
'Open the "InputData" form.
.DoCmd.OpenForm "InputData"
.Forms![InputData]!txtData.SetFocus
.Forms![InputData]!txtData.Text = "Demo Data"
'Call Procedure "StoreData" on Access Form "InputData"
HELP!
End With
Microsoft Access Form from an Excel Form. I've created the
Access object, opened the database containing the form,
displayed the form, autofilled some textboxes, but I can't seem
to get the correct syntax to call one of the access form's
procedures. This is what I have so far:
I have an Access form called InputData
It has a textbox called txtData
From within an Excel form I have this code:
Dim appAccess As Object 'Microsoft Access database object
'Create an instance of Microsoft Access
Set appAccess = CreateObject("Access.Application")
With appAccess
'Open the database "ABC.mdb"
.OpenCurrentDatabase "C:\My Documents\ABC.mdb"
'Open the "InputData" form.
.DoCmd.OpenForm "InputData"
.Forms![InputData]!txtData.SetFocus
.Forms![InputData]!txtData.Text = "Demo Data"
'Call Procedure "StoreData" on Access Form "InputData"
HELP!
End With





RE: Call Access form procedure from Excel form
Them inside your with loop:
.Forms![InputData]!cmdMyButton.Click()
That should work.
RE: Call Access form procedure from Excel form
Private Sub CommandButton1_Click()
'Microsoft Access database object
Dim appAccess As Object
Dim en As String
Dim r As Integer
Dim c As Integer
Set myrange = Range("A10:A60")
'Create an instance of Microsoft Access
Set appAccess = CreateObject("Access.Application")
'Open the database "RDS.mdb"
appAccess.OpenCurrentDatabase "M:\rds.mdb"
'Open the "ESU form" form.
appAccess.docmd.OpenForm "ESU form"
appAccess.Forms![ESU form]!txtEN.SetFocus
r = 1
c = 1
For r = r To 50
en = myrange.Cells(r, c)
If en = "" Then
r = "50"
Else
appAccess.Forms![ESU form]!txtEN = en
appAccess.Forms![ESU form]!cmdMyButton.Click()
End If
Next r
'close access
appAccess.Application.Quit acEXIT
Set appAccess = Nothing
End Sub
AFTER I entered appAccess.Forms![ESU form]!cmdMyButton.Click() I get a compiler error expected =
I am new with VBA please help if I use = true then I get a runtime error 2465
please help
Todd