determining the name of the textbox focused

J

jonefer

I want to write a public function for about 8 different textboxes.

How can I refer to the name of the textbox so I can referentially change the
code for each textbox, with one generic piece of code?

The code, placed in the before update event would go something like this:

Public Function CheckDateValidity()

Select case NameOfTextBoxI_am_in
case ReceivedDate
msgbox "Custom message for Received date textbox"
case EnteredDate
msgbox "Custom message for Entered Date textbox"
End Select

End Function
 
G

Graham Mandeno

Hi Jonefer

Use Me.ActiveControl if your code is in the form's class module, or
Screen.ActiveControl if the code is in a standard module.

The .Name property will give you the name of the control, and of course
..Value will give you the contents.
 
J

jonefer

Perfect. Thanks.

Graham Mandeno said:
Hi Jonefer

Use Me.ActiveControl if your code is in the form's class module, or
Screen.ActiveControl if the code is in a standard module.

The .Name property will give you the name of the control, and of course
..Value will give you the contents.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

jonefer said:
I want to write a public function for about 8 different textboxes.

How can I refer to the name of the textbox so I can referentially change
the
code for each textbox, with one generic piece of code?

The code, placed in the before update event would go something like this:

Public Function CheckDateValidity()

Select case NameOfTextBoxI_am_in
case ReceivedDate
msgbox "Custom message for Received date textbox"
case EnteredDate
msgbox "Custom message for Entered Date textbox"
End Select

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top