I have a textbox on top of the form and 2 underlying command buttons. When the textbox gets the focus, the first command button is disabled. When the text has been validated, this button is enabled and is supposed to receive the focus, but the other button gets the focus instead. What have I done wrong? (See attachment)
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I've found an easier solution: placing the reenabling code line in the textbox lostfocus event, as follows.
VB Code:
Private Sub Text1_GotFocus()
Command1.Enabled = False
End Sub
Private Sub Text1_LostFocus()
Command1.SetFocus
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
Dim i As Long
Command1.Enabled = True
End Sub
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
But, that won't work if the text in text1 is not validated as ok, that's why i added a boolean
I meant, place the command2.setfocus (not command2.enabled=true, my mistake) in the textbox.lostfocus event. At any rate the code I've posted works, try it.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)