Function as event handler

  • Thread starter Thread starter Gary Schuldt
  • Start date Start date
You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Trina Gray said:
Thank you! Thank you! Thank you! I put everything in place per your
instruction and it worked perfectly.

Thanks again,
Trina Gray

Ken Snell said:
Regular module means a module that you create from the database window.

To use the function as the event handler, type this in the property box next
to After Update event on the Event tab for the textbox's Properties:

=MyUcase()

--

Ken Snell
<MS ACCESS MVP>

Trina Gray said:
By regular module are you refering to creating a new module? Please explain
how I "use MyUcase() as the event handler function".

Thanks,
Trina Gray

:

You don't put the function in the form's module.

Create this function in a regular module:

Public Function MyUcase() As String
Screen.ActiveControl.Value = UCase(Screen.ActiveControl.Value)
End Function

Then use MyUcase() as the event handler function.

--

Ken Snell
<MS ACCESS MVP>

I cannot get this code to work. Please tell me what I am doing wrong.

I opened the properties for the field that I wish to have converted to
uppercase, Clicked the "..." button on the "After Update" line under
"Event"
tab.
Selected "Code Builder" from options.
Pasted the suggested code but it still did not work. Am I supposed to
replace "Screen", "ActiveControl" and/or "Value" with specific
information?

Trina Gray


:

Ah, that's the trick! I remember now:

1. It HAS to be a user function to be used in one-liner event handler
context

2. It doesn't matter what the function value is set to

3. The function code (or something it calls, like a Sub) must
set
the
value(s) you want.

How COULD I have forgotten?? <g>

Thanks,

Doug

Actually, you need to set the value of Screen.ActiveControl. It
doesn't
matter whether or not the function returns a value:

Public Function MyUcase() As String
Screen.ActiveControl.Value = UCase(Screen.ActiveControl.Value)
End Function


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I believe you must create your own function and call it, not
use
the
built-in function that requires an argument.

Create this function in a regular module:

Public Function MyUcase() As String
MyUcase = UCase(Screen.ActiveControl.Value)
End Function


Then use MyUcase() as the event handler function.

--

Ken Snell
<MS ACCESS MVP>

I thought I could code a function reference in the event-handler
box
for
a
control, but I'm missing something, since I can't get it
to
work.
I want to make a text field all upper case AfterUpdate.

The Expression Builder guides me through to yield the entry:

=Ucase([txtFld])

but it doesn't work. When I type lower-case letters into the
field
and
tab
out, they remain lower-case.

I know I've seen this done before!

Gary
 
Back
Top