getting the last textbox that was focussed on and placing the focus on it
Hello
Is it possible to get the last textbox that was focussed on set the focus back on it.
what i mean is say i had footext1.text and then moved to footext2.
and then due to an error condition, i want to go back to footext1,
is it possible to get the last "focussed textbox" and then select that textbox again?
Re: getting the last textbox that was focussed on and placing the focus on it
do your errorcheck in the Validate event of the checkbox...
Setting cancel to true will stop it from going to the next checkbox
like this:
VB Code:
Private Sub footext1_Validate(Cancel As Boolean)
If CheckForErrorIsError Then
Cancel = True
footext1.SelStart = 0
footext1.SelLength = Len(footext1)
End If
End Sub
Re: getting the last textbox that was focussed on and placing the focus on it
thanks for the reply
is the validate method used when the textbox is about to go out of focus?
i guess the footext1.length repastes the text previously in the textbox, correct?
i guess the checkforerror is a flag, and i should probably name itas footextcheckforerror and initialise it to True in the form_load method, correct?
Re: getting the last textbox that was focussed on and placing the focus on it
no :)
ok..
the the selstart & sellength are to make it Highlight the text in the textbox so when the user types it will replace whats there...
the checkforerror was just made up.. you need to put your code in to check for the error. (not sure what you are checking for)
Re: getting the last textbox that was focussed on and placing the focus on it
thanks for the reply [A51g]Static
is the answer no, for both my questions
1. is the validate method used when the textbox is about to go out of focus?
2. i guess the footext1.length repastes the text previously in the textbox, correct?
can you tell me when the validate method is fired?
is .selstart = 0 right before the first character
and is .selstart = 3 possible?
i guess if i have a textbox footext and then do
do
followed by
the .selstart value resets itself, correct?
Re: getting the last textbox that was focussed on and placing the focus on it
1)yes, the validate fires as soon as you try to leave the textbox
2) the sellength is just setting how many characters to Select (Highlight)
you can set selstart anywhere in the textbox
selstart just places the cursor in that position
and yes, if you set selstart = 2 then change the text in the textbox, selstart goes back to 0
Re: getting the last textbox that was focussed on and placing the focus on it
thanks for clearing my misunderstandings static