Results 1 to 7 of 7
  1. #1
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33

    Set onclick via VBA

    I have a form that's used for setting parameters for various reports as they open. I have a procedure set on the OnLoad of each report to open this form. In that event, I need to change the OnClick event procedure for the form's Cancel button so that it would close both the form and the report.



    Report: rptAgentByDate (as a sample)
    Form: frmReportParams
    Button: frmReportParams!cmdCancel

    If anyone can point me to a resource on this, or post a bit of sample, it would be greatly appreciated. Trying to search for this proved useless, as "onclick" isn't terribly useful in a search.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do you pass your ReportName to the form that you are opening? You could in the OpenArgs argument.

  3. #3
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33
    Getting the name to it isn't an issue - plenty of ways to do that, since it's actually opened by the report's OnLoad event. I need to set the OnClick event of that button, though. That's my limitation.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The OnClick event of the cmdCancel button just needs to look at the OpenArgs to close the report. No need to alter the code in the event.

  5. #5
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33
    Never thought of that. Much simpler answer. I'll have to look through the routines I'm working on and see if there are any other changes I needed in that event. If not, this will solve it easily.

    Thanks for giving me a better idea!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're most welcome. Are you ready to follow the link in my sig and mark this thread as Solved?

  7. #7
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33
    Dang - forgot to do that last night. Thanks for the reminder!

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

Similar Threads

  1. OnClick event
    By HotTomales in forum Forms
    Replies: 1
    Last Post: 12-24-2009, 08:10 PM

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