×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Call Access form procedure from Excel form

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

RE: Call Access form procedure from Excel form

Assuming that the StoreData() procedure is invoked using a command button (if not, add a command button, give it a name, have it call the form's procedure - you can set the button to Visible=No if you want)...

Them inside your with loop:
  .Forms![InputData]!cmdMyButton.Click()

That should work.

RE: Call Access form procedure from Excel form

I am also having a problem calling a procedure from excel


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources