Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automation question... (97 SR-2)

    Hi Everyone...

    Just curious... Can someone tell me if it is possible to execute an On Click event for a command button in a remote database...

    So far, from within one database:
    - I've gotten the other database to open
    - Opened a form in that database
    - Set a value for an option button to True
    - Set focus on the command button on that form

    Now all I need to do is get it to click... <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> ...or the equivalent of clicking... I need the code to run for that click event...
    Can't figure it out...

    Is this possible?
    TIA

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Automation question... (97 SR-2)

    In general, all you do is simply execute the procedure name associated with that object. You need to be sure to have reference set to that database, but that should do it.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation question... (97 SR-2)

    Thanks Wendell... but the problem I'm having is with the syntax...
    This is what I have so far for the code...

    Dim acApp As Object ' Declare variable to hold the reference.
    Dim acDatabase As DAO.Database

    Set acApp = GetObject("Cocuments and SettingstreaspaDesktopdb1.mdb")

    With acApp
    .Visible = True
    .DoCmd.OpenForm "Form1"
    .Forms("Form1").frmOptions = 1
    .Forms("Form1").cmdDone.SetFocus
    'cmdDone_Click 'this is where I don't know how to enter the command... I've tried a few things but I can't get it right...
    .Quit
    End With

    Set acApp = Nothing

    End Function

    P.S. This is just a sample... Not the real thing...

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Automation question... (97 SR-2)

    Have you tried replacing
    .Forms("Form1").cmdDone.SetFocus
    by
    .Forms("Form1").cmdDone_Click

    This is just a hunch.

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation question... (97 SR-2)

    Thanks Patt, but that's one of the things I tried... <img src=/S/sad.gif border=0 alt=sad width=15 height=15>
    I get error 'Runtime Error 2465 - Application-defined or Object-defined error"

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Automation question... (97 SR-2)

    If you look at the code behind cmdDone_Click you will probably find that it is private which means that this procedure is not visible and available outside this form.
    Changing private to public made it work for me.
    Regards
    John



  7. #7
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation question... (97 SR-2)

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15> ... Ahhh... The scope... I should have thought of that...
    Thanks a million John!
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •