Results 1 to 1 of 1
  1. #1
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109

    Refer to class object in parent form

    Hi Guys,



    Despite the fact Access VB is not object-oriented-programming friendly, I struggle to do as much as possible with usage of class modules. That's why I created clsSearch class to handle search events on different forms. I'm creating new instance of clsSearch on form_open and remove it on form_close event. The instance is a private object of the form for which it's supposed to handle search events. The problem I have now is that I want to reassing ctrl+F to be handled by my object. This is not a problem on the main form, I just put:

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Call srch.replaceCtrl_f(KeyCode, Shift)
    End Sub
    srch is the object and replaceCtrl_f is its method to handle ctrl+F press event.
    Unfortunately, most usually main form doesn't react properly on ctrl+F as, probably, subForm is in focus and it receives KeyDown event rather than main form. My question is: how can I refer to main form's object from subform? I need to be able to trigger its replaceCtrl_f method but srch is not recognized by subform as it's main form private object.. How can I get round that?

    Robert

    The solution I've chosen is to make mainform's keydown event public and call it from the subform.
    Last edited by robs23; 07-22-2015 at 12:36 PM. Reason: SOLUTION FOUND

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

Similar Threads

  1. call class function from object
    By Ruegen in forum Programming
    Replies: 2
    Last Post: 01-20-2015, 09:51 AM
  2. Need VBA code/"Class Object" for a bound form
    By kewelch in forum Programming
    Replies: 6
    Last Post: 06-27-2013, 09:26 AM
  3. Replies: 1
    Last Post: 04-26-2012, 12:14 AM
  4. Object or class does not support the set of events??
    By mejia.j88 in forum Programming
    Replies: 5
    Last Post: 12-12-2011, 12:01 PM
  5. object or class does not support the set of events
    By couch potato in forum Programming
    Replies: 2
    Last Post: 03-20-2010, 08:55 AM

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