automation: how to run form event?

  • Thread starter Thread starter david epsom dot com dot au
  • Start date Start date
D

david epsom dot com dot au

Set objCTM = wscript.CreateObject("Access.Application.9")

objCTM.visible = true

objCTM.OpenCurrentDatabase("c:\program files\capix\bk9.mde")

objCTM.RUN "gfnMenuBK_BankDownload" 'load form

set objFRM = objctm.forms("frmBK_BAITrans_Import")


Now, how would I run a button click event on that form?
Can I use Run, Eval, CallByName, Call, Execute or what?

Or do I have to put the call into a function in a standard
module?


(david)
 
The following worked for me, David. Of course, I had to change the
declaration of the event from the default 'Private' to 'Public' ...

Set objCTM = wscript.CreateObject("Access.Application")
objCTM.visible = true
objCTM.OpenCurrentDatabase("c:\dsapps\db73.mdb")
objCTM.DoCmd.OpenForm "Form1" 'load form
set objFRM = objctm.forms("Form1")
objFRM.Command0_Click

I experimented briefly with the idea of adding a single public method to the
form which would use CallByName to call other, private methods, rather than
having to change the declaration of every method, but was unable to get that
to work. The alternative below does work, though it isn't terribly elegant
....

Private Sub PrivateSub()
MsgBox "This is PrivateSub"
End Sub

Public Sub PublicSub(ByVal strProcName As String)
Select Case strProcName
Case "PrivateSub"
PrivateSub
Case Else
MsgBox "Huh?"
End Select
End Sub

Set objCTM = wscript.CreateObject("Access.Application")
objCTM.visible = true
objCTM.OpenCurrentDatabase("c:\dsapps\db73.mdb")
objCTM.DoCmd.OpenForm "Form1" 'load form
set objFRM = objctm.forms("Form1")
objFRM.PublicSub "PrivateSub"
 
Back
Top