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

    Detect From Main Form When Subform's Source Object Changes

    Hi Guys,

    actually the whole point of my question is in the title. But of course I'll elaborate for better understanding what I'm trying to achieve.
    I have a main form and a subform on it. Subform shows data in datasheet view. I use main form as a kind of navigation panel - I change subform's source object by clicking controls on main form. It works ok.


    Now, however, I'd like to find out a way to detect subform's source object change. It'd be best if there is a form/subform event that is triggered in such condition. I know I can detect it with control's events (e.g. button_click) on main form but this IS NOT what I'm looking for.

    A help here is appreciated.

    Robert

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    can you be more specific about 'detect subform's source object change' Are you talking about a control source change, i.e. you force a control source change on your subform with a button click on the main form, then you want to detect when that change is actually complete? or do you have some tools on your subform that also force changes within the subform and you want those events to trigger something on your main form?

  3. #3
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109
    Hi rpeare,

    Thank you for answer. It's actually a something else. I have a "filter" class in my project. I create an instance of this class on main form's load and kill it on close. This class can handle cotrols' events or main form's events thanks to "WithEvents" method. This maximize code's reusability - I can use this object on many forms and in many projects without much hassle. For example I use object with "WithEvents" to replace Access standard ctrl+F window - the object grasps cotrol_keyDown event and trigger built-in method to place cursor into filter textbox.
    Now, it works very good with standard forms. Unfortunately, in my previous project I made a form containing subform, and with main form's buttons I change subform's source cotrol to present different queries. I know it's not the best way but at that time I couldn't do any better and now I don't want to change it. So now I have to find a way to detect when suboform's source object changes and trigger procedure. It has to be handled by "filter" object and due to this it has to be done from main form. The question is: how can I do that? I'll be explicit - I don't want to place any code on subform itself as it would break the reusability.

    Robert

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you supply a pared down sample of your database with just the tables/forms in question as an example and then explain exactly which event (what buttons/controls/keystrokes) you are hoping to detect the control source change on. When you create your sample database get rid of any confidential items and just put enough data in to simulate the data and problem, then compact/repair the sample database, zip it up and upload it to this site for examination.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Not sure my suggestion will fit, but I had a situation where I had to trap changes in form or subform record. The IsDirty property wasn't working because once a record on the sub was committed, the property was False, so I couldn't detect changes from the main form button events. The solution was to create a higher level variable bolIsDirty that I could check. For me, the declarations section at the top of the main form was sufficient since the button code was on the main form. For you, I'm not sure if on the main form, or as a public variable in a standard module. So, the suggestion is to set a variable that will remain in scope at the point you change the property or value and test it when you need to.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-06-2014, 05:35 AM
  2. Replies: 5
    Last Post: 10-14-2014, 04:08 PM
  3. Main form and subform
    By jle0003 in forum Forms
    Replies: 4
    Last Post: 07-08-2014, 09:23 AM
  4. Replies: 3
    Last Post: 04-17-2012, 10:28 AM
  5. Replies: 2
    Last Post: 10-18-2010, 07:53 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