Auto load beforeUpdate event

I have about 300 text fields to load a function into the beforeUpdate event.  Is there a way to auto load the function in all the desired text fields?
tru-numbersAsked:
Who is Participating?
 
andrewssd3Connect With a Mentor Commented:
I don't know of a quick way to do this.  You can create a class module to contain the controls and handle the events in one place as described here: http://social.msdn.microsoft.com/Forums/da/isvvba/thread/60230abd-7ebb-45bf-a24a-bfde3679eb21. However the problem with this for you is that dynamically created text boxes don't support the before_update event - you only have Click, Change and some others, but they may not do what you want.  
Alternatively, if the controls all exist at design time and are not created dynamically, why no just write a simple loop to generate the necessary event handler code for all the controls into the immediate window or a text file and paste it into your userform?
0
 
andrewssd3Commented:
Can you give some more details please?  What are the text felds - do you mean text boxes on a userform, or are they cells in an Excel workbook.  beforeUpdate sounds as if a userform is involved.  What exactly are the functions you want to put in them?  Perhaps you could post the code you already have then it wil be easier for someone to help you.

Stuart
0
 
tru-numbersAuthor Commented:
Thanks andrewssd3,

Fields are on a userform.  I want to insert
Call getControlInfo(ActiveControl)
to the fieldName_beforeUpdate event

I check the user entry with this code and its' as follows:

    If TypeOf ctrl Is MSForms.Frame Then
        Set getControl = getControlInfo(ctrl.ActiveControl)
   
    ElseIf TypeOf ctrl Is MSForms.MultiPage Then
        Set getControl = getControlInfo(ctrl.Object.SelectedItem.ActiveControl)
   
    Else
        Set getControl = ctrl
        frmProgramAdmin.fldName = ctrl.Name
        frmProgramAdmin.fldValue = ctrl
       
        If validDate(frmProgramAdmin.fldValue) = False Then
            frmProgramAdmin(ctrl.Name) = ""
       
        End If
   
       
        If validNumber(frmProgramAdmin.fldValue) = False Then
            frmProgramAdmin(ctrl.Name) = ""
       
        End If
       
    End If
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
tru-numbersAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for tru-numbers's comment #37831970

for the following reason:

I did this in error
0
 
andrewssd3Commented:
Even so, I did give some relevant help with supporting documentation, so it would be good to allocate some points at least rather than just deleting the question altogether.
0
 
tru-numbersAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.