Subrat
Subrat

Reputation: 5

Clicking a button in Access Form using VBA Excel

This is my code below. I am getting an error "Object doesn't support this property or method" on controls.click. Anyone there who can help?

    'create new access object
    Set appAccess = CreateObject("Access.Application")
    'open the acces project
    Call appAccess.OpenCurrentDatabase("D:\NSE Cash\db.accdb")
    appAccess.Visible = True
    With appAccess
        Application.DisplayAlerts = False
        .DoCmd.OpenForm "Form1"
        .Forms("Form1").Controls("Run").Click
    End With
    Set appAccess = Nothing

Upvotes: 1

Views: 1129

Answers (1)

June7
June7

Reputation: 21370

First, the button Click event cannot be Private - remove Private from the procedure declaration. Then, this works for me:

.Forms("Form1").Run_Click

Upvotes: 1

Related Questions