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

Doug Murphy dw-murphy at cox.net
Thu Oct 31 19:07:36 CDT 2013


Brilliant Anita item 3 was it. Just changing the routine DataCheck to a
function allowed it to work. Form works great now with all afterupdate
events being set on form load. If value entered is out of limits for that
particular measurement the dialog comes up where notes are entered, and
operator has the option of accepting value with no note, going back to the
value just entered, or leaving as is and saving the note with associated
parameters in a separate table. 

Something so simple.

Thanks again.

Doug

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Anita Smith
Sent: Thursday, October 31, 2013 4:17 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Attach an afterupdate event handler to all text boxes
on form

I'm not sure I get what it is you are trying to do here, but if all you want
is to avoid having to go to every textbox's after update event in the code
window then you could do the following; 1. Multi select all your text boxes
2. On the property sheet in the after update event enter =DataCheck() 3.
Change your DataCheck procedure to a Function

Anita Smith


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby
Sent: Friday, 1 November 2013 10:04 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Attach an afterupdate event handler to all text boxes
on form

Do it with a class?
On Oct 31, 2013 6:36 PM, "Doug Murphy" <dw-murphy at cox.net> wrote:

> 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
>


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list