Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

value of current field in form 3

Status
Not open for further replies.

nycdata

Programmer
Jun 28, 2004
26
US

Is there a way to find out the field of the form where the user is currently focused..

Like, i have a user on a form, and he is changing a field...is it possible to find out which field it is that the user is on or the user is editing...

IT IS REALLY IMPORTANT!!

Any help will be greatly appreciated!!!!!
 
Hi,

All controls have a .lostfocus and .gotfocus event.

In gotfocus, you could set a form variable to hold the name of the field.

e.g.

In <form_open> event:

DIM FieldWithFocus

In each field <On Got Focus> event:

FieldWithFocus = "fieldname"

You can then check the 'FieldWithFocus' variable to get what you want.

There will be a simpler way of doing this shortly (no-doubt), but you have at least got one solution.

Regards,

Darrylle




Never argue with an idiot, he'll bring you down to his level - then beat you with experience. darrylles@yahoo.co.uk
 
Take a look at ActiveControl

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank-you PHV, if I may elaborate, due to my new enlightenment...

Here's a little snippet, I got from "Help".

Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name


It may require a little thought, on how you run this, or which event you put it on, in order to not prematurely change the focus.

Maybe a global variable, and the on change event of every form?

Depending on your objective..

If strControlName = "txtField1" Then
MsgBox "EmployeeRate must be entered, before editing the deductions field"

Hope this helps.
Thanks again, PHV!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top