SITUATION: I have a userform (A_MAIN) that displays a few command buttons. If the user presses the command button "Add" an additional userform (B_ADD) populates or if the user presses the command button "Modify" a different userform (C_MODIFY) populates. While each userform serves a separate and distinct function, they nevertheless share one thing in common - they all use four combo boxes (CB_FUNC, CB_COMP, CB_BLN, CB_FLN) and a textbox (TB_KEY) in the exact same way. That is, the user selects an option from a given combobox and the "key" lookup value generates in TB_KEY. With these look up values, I can find anything in my data tables (see the "parts" tab).
PROBLEM: As it stands now, I copied and pasted the change events and initialization routines into each userform. While that works fine, it creates a lot of redundant coding (it’s now in three different places). I would like to centralize the code into one place. Please see the attached file to see more (NOTE: I got rid of any additional coding that is not directly involved in this problem in the attached file, I hope that helps).
ATTEMPTED SOLUTION: I created a module and tried to create a public sub for the initalization and each change event to call. It doesn't work the way I intended…any help would be greatly appreciated. The redundant coding, used in each userform, is as follows:
![]()
Please Login or Register to view this content.
Bookmarks