Solved

Auto load beforeUpdate event

Posted on 2012-04-10
6
397 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
ID: 37831408
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
ID: 37831970
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
ID: 37832214
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:tru-numbers
ID: 37902717
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
ID: 37902718
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
ID: 37903481
Thanks
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

821 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