Solved

Auto load beforeUpdate event

Posted on 2012-04-10
6
370 Views
Last Modified: 2012-04-27
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?
0
Comment
Question by:tru-numbers
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:andrewssd3
Comment Utility
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
 

Author Comment

by:tru-numbers
Comment Utility
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
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 500 total points
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:tru-numbers
Comment Utility
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
 
LVL 17

Expert Comment

by:andrewssd3
Comment Utility
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
 

Author Closing Comment

by:tru-numbers
Comment Utility
Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now