Field Names

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

Guest

I would like to assign a field name to a variable when a user enters into the
field. SO if the cursor enters a field named txtLName, I want to asign
"txtLName" to a variable. Any assistance will be apreciated.
 
Create a function along the lines of:

Dim mtxtCurrentControl As String

Function WhatField()
mtxtCurrentControl = ActiveControl.Name
End If

Now, select all of the controls on the form for which you want to do this.
Select Properties, and in the On Enter property, put =WhatField()
 
u r da man. One question, couldn't I just put the code in the OnEnter
property? What is the benifit of creating a function?
 
Not sure what you're doing here...
You shouldn't use the same name as your field name for your variable name...

Using the OnEnter event of [txtLName]

Dim varLName as String
varLName = Me.[txtLName]

hth
Al Camp
 
Back
Top