[AccessD] Attach an afterupdate event handler to all text boxes on form

Doug Murphy dw-murphy at cox.net
Thu Oct 31 17:34:55 CDT 2013


Folks,

This has probably been discussed in the event handling discussions of past
years but I can't find them. I have a data entry form with many text boxes.
The form is used by folks in a lab to enter daily readings.  Each reading
has a set of parameters it is supposed to be within. If not a dialog pops up
so the person entering can add notes for the reading. All this works well
when I create an event handler for a given text box and enter the call to
DataCheck(). The routine the after update handler calls gets the recordID,
control name, parameters the values is supposed to be between, and the value
entered and performs the comparisons and pops up the dialog if the value is
out of bounds. I am thinking I should be able to put some code in the form
on load event that would set all the text boxes after update events to my
data check routine. I created a routine to do this, see below, but when I
test the form I get a message "The expression After Update you entered as
the event property setting produced the following error: The object doesn't
contain the Automation object 'DataCheck". 

Any suggestions?

Public Sub SetTextBoxProperties()
    Dim ctl As Control
   On Error GoTo SetTextBoxProperties_Error
    For Each ctl In Me
        If ctl.ControlType = acTextBox Then
            ctl.AfterUpdate = "=DataCheck"
        End If
        
    Next
    
SetTextBoxProperties_Exit:
   On Error GoTo 0
   Exit Sub

SetTextBoxProperties_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & " at Line Number
= " & Erl & ") in procedure SetTextBoxProperties"
    Resume SetTextBoxProperties_Exit:
    Resume
End Sub



More information about the AccessD mailing list