vba - Best method to allow an event to work on a form -


in vba have subform use on many forms; have bit of code want code work on 'one form'; if have subform textbox in form 1, form 2 , form 3, want after update event work form 2.

what's best possible way go doing this?

a subform has parent property. can check name property of subform's parent.

dim strparent string strparent = me.parent.name if strparent = "form 2"     ' stuff form 2 end if 

notes:

  1. that code intended after update event of text box on subform. if target text box present on parent form instead, it's simpler; check parent form's name directly (me.name).
  2. if subform opened on own, ie not subform form, me.parent throw error. need trap error , ignore it.

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -