Results 1 to 6 of 6
  1. #1
    Sean Nakasone is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    2

    External script to call Command Button Click event handler

    Hi, I'm trying to use an external script (like powershell, vbscript, jscript) to call the event handler for the click event of a Command button. Using ms-access 2010 on Windows 7 (64-bit). Or to send the click event itself. Can't figure it out. suggestions?

    That's the gist of it, but here's more information which might help...

    I am able to create a VBA standard module in Access and create a simple wrapper function that calls the event handler, i.e.

    Public Function MyWrapperFunction()
    Call MyForm.MyPushButton_Click
    End Function

    I am able to call this wrapper function from an external powershell script, i.e.
    $accApp = New-Object -ComObject Access.Application
    $accApp.OpenCurrentDatabase("c:\folder\myAccessDat abase.mdb")
    $accApp.Visible = $True


    $accApp.run("MyWrapperFunction")

    But I would prefer to just call the event handler, MyForm.MyPushButton_Click, directly from the external script.

    The main reason is because I'm not the developer of the access database, I'm just the developer of the external script.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Hmmm. You need to establish addressability to the form, which is in the Forms collection of the App. The syntax of your script is going to look the same until the last line, which is going to be something like... blagh, I can't find my reference right this second. You'll run down the objects enumerating each step something like this -

    App -> Forms -> the one form -> the control -> the method

    I'll see if I can find it for you in the morning. Hopefully, someone who's carrying around this stuff in their head (June, RuralGuy?) will have already typed in the right syntax for you by then.

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    See, you can't get quicker than that. June gave it to you before I hit "post quick reply".

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Just did a quick search in the forum because I remembered dealing with the same topic.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Sean Nakasone is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    2
    Thanks Dal and June7, I was able to drilldown to the Form's COM object and call it's method using JScript.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. On click event script
    By VOLB in forum Programming
    Replies: 2
    Last Post: 02-21-2014, 03:44 PM
  2. Trigger event with button click
    By AMAS in forum Forms
    Replies: 8
    Last Post: 06-07-2012, 09:42 AM
  3. Form command button to do something/call function
    By shubhamgandhi in forum Programming
    Replies: 2
    Last Post: 07-27-2011, 04:45 PM
  4. Command button click event
    By R_jang in forum Programming
    Replies: 10
    Last Post: 10-29-2010, 10:13 PM
  5. On Click Event For Button On Form
    By Desstro in forum Forms
    Replies: 3
    Last Post: 08-09-2010, 02:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums