determining the name of the textbox focused

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
Back
Top