kkbenj
asked on
VB6 Problems with SetFocus
I checked my version and it is 6. But I do not have SetFocus as an option on my textbox. Am I missing a setting?
A textbox doesn't have a SetFocus "option". It has a SetFocus "command" that you call.
If you are not seeing "SetFocus" in the auto-complete, try typing it anyway.
Specifically, try creating a new project and place two textboxs and two command buttons on the form. Then put the following code inside the form and see if it will compile and execute.
Private Sub Command1_Click()
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Text2.SetFocus
End Sub
If you are not seeing "SetFocus" in the auto-complete, try typing it anyway.
Specifically, try creating a new project and place two textboxs and two command buttons on the form. Then put the following code inside the form and see if it will compile and execute.
Private Sub Command1_Click()
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Text2.SetFocus
End Sub
ASKER
I have forced the SetFocus even though it does not present. It gives this error:
Compile error:
Method or data member not found
Compile error:
Method or data member not found
Is the error about 'SetFocus' method or is it because you misspelled textbox name or because your code cannot see the textbox or is in wrong context?
Maybe give some sample code or more details.
Maybe give some sample code or more details.
ASKER
The code and I always cut and paste field names to ensure I don't misspell.
When I click the New button, is highlights the .SetFocus and displays the compile error above.
When I click the New button, is highlights the .SetFocus and displays the compile error above.
Private Sub btnNext_Click()
txtParmNm.SetFocus
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes - that was the problem. Thanks!
You're welcome.
There should be a SetFocus method on the TextBox.
TextBox1.SetFocus