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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to SetFocus Again?

Status
Not open for further replies.

needadvice

Programmer
Apr 7, 2002
145
US
I have an on-click event that by necessity sets focus on a field to determine the value of the field. That's fine, but the user wants to return the focus to the first textbox on the form. Once focus is set on a control, is there a way to reset the focus to another control. It stops on the initial setfocus control and seems like no commands work after that.
 
Dim name
Dim Lastname As String


name = [Referred By].Value

If IsNull([LAWYER LNAME]) Then
[LAWYER LNAME].SetFocus
[LAWYER LNAME].Text = "Sir"
[Company].SetFocus

End If

If IsNull([UNION REP LNAME]) Then
[UNION REP LNAME].SetFocus
[UNION REP LNAME].Text = "Sir"

End If
 
Well, without looking at the whole program to see what exactly you are trying to do here, I would say the you shouldn't need the [LAWYER LNAME].SetFocus before the
.Text = "Sir", as you seem to be refering to it by name.
If
If IsNull([LAWYER LNAME])
can be determined by VB, then
[LAWYER LNAME].Text = "Sir"
should work without
[LAWYER LNAME].SetFocus.

If the if event is firing and the code and names are valid, the second .setfocus should work also - you should be able to .setfocus through every control on the page in one event if you want. So I guess the next question is...

What kind of control/field is [LAWYER LNAME]
Is the if event firing?
Does the [LAWYER LNAME].SetFocus command work?
Does the [LAWYER LNAME].Text = "Sir" work ? (your message appears to say it does not). Failing everything else, if this is not a huge program, you can email it to me and I can take a quick look at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top