|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I put the focus back in a text boxThis shoud be a simple problem to fix but it is perplexing me. I have the following in my LostFocus event. If the condition exists, I'd like the focus to go right back to the CustomerDirectory textbox. If Not fs.FolderExists(CustomerDirectory.Text) Then MsgBox "Bad customer directory, try again", vbExclamation + vbOKOnly CustomerDirectory.Text = "J:\ML\" ' set directory to default End If 'CustomerDirectory_GotFocus ' this doesn't work Can anyone point me in the right direction? Regards Dale Jones CustomerDirectory.SetFocus
Show quoteHide quote "Dale" <D-Man> wrote in message news:eoHRvngYFHA.3132@TK2MSFTNGP09.phx.gbl... > Hi all > > This shoud be a simple problem to fix but it is perplexing me. > > I have the following in my LostFocus event. > > If the condition exists, I'd like the focus to go right back to the > CustomerDirectory textbox. > > > If Not fs.FolderExists(CustomerDirectory.Text) Then > > MsgBox "Bad customer directory, try again", vbExclamation + > vbOKOnly > CustomerDirectory.Text = "J:\ML\" ' set directory to default > > End If > > 'CustomerDirectory_GotFocus ' this doesn't work > > > Can anyone point me in the right direction? > > Regards > Dale Jones > One of two:
Use the txtCustomerDirectory.Setfocus event Or better, move your validation code to the validate event and if your validation does not pass mustard, return True in the Cancel parameter. But do not call the Got focus event directly, this event fires when the control receives focus, but does not set focus. Good luck! Saga Show quoteHide quote "Dale" <D-Man> wrote in message news:eoHRvngYFHA.3132@TK2MSFTNGP09.phx.gbl... > Hi all > > This shoud be a simple problem to fix but it is perplexing me. > > I have the following in my LostFocus event. > > If the condition exists, I'd like the focus to go right back to the > CustomerDirectory textbox. > > > If Not fs.FolderExists(CustomerDirectory.Text) Then > > MsgBox "Bad customer directory, try again", vbExclamation + > vbOKOnly > CustomerDirectory.Text = "J:\ML\" ' set directory to default > > End If > > 'CustomerDirectory_GotFocus ' this doesn't work > > > Can anyone point me in the right direction? > > Regards > Dale Jones > Correction:
txtCustomerDirectory.Setfocus is a method, NOT event Sorry Saga Show quoteHide quote "Saga" <antiSpam@somewhere.com> wrote in message news:Om3vezgYFHA.2128@TK2MSFTNGP15.phx.gbl... > > > One of two: > > Use the txtCustomerDirectory.Setfocus event > > Or better, move your validation code to the validate event and > if your validation does not pass mustard, return True in the Cancel > parameter. > > But do not call the Got focus event directly, this event fires when > the control receives focus, but does not set focus. > > Good luck! > Saga > > "Dale" <D-Man> wrote in message > news:eoHRvngYFHA.3132@TK2MSFTNGP09.phx.gbl... >> Hi all >> >> This shoud be a simple problem to fix but it is perplexing me. >> >> I have the following in my LostFocus event. >> >> If the condition exists, I'd like the focus to go right back to the >> CustomerDirectory textbox. >> >> >> If Not fs.FolderExists(CustomerDirectory.Text) Then >> >> MsgBox "Bad customer directory, try again", vbExclamation + >> vbOKOnly >> CustomerDirectory.Text = "J:\ML\" ' set directory to default >> >> End If >> >> 'CustomerDirectory_GotFocus ' this doesn't work >> >> >> Can anyone point me in the right direction? >> >> Regards >> Dale Jones >> > > Thanx a lot guys.
Show quoteHide quote "Dale" <D-Man> wrote in message news:eoHRvngYFHA.3132@TK2MSFTNGP09.phx.gbl... > Hi all > > This shoud be a simple problem to fix but it is perplexing me. > > I have the following in my LostFocus event. > > If the condition exists, I'd like the focus to go right back to the > CustomerDirectory textbox. > > > If Not fs.FolderExists(CustomerDirectory.Text) Then > > MsgBox "Bad customer directory, try again", vbExclamation + > vbOKOnly > CustomerDirectory.Text = "J:\ML\" ' set directory to default > > End If > > 'CustomerDirectory_GotFocus ' this doesn't work > > > Can anyone point me in the right direction? > > Regards > Dale Jones > Dale wrote:
Show quoteHide quote > Hi all Oh, and slightly off-topic, I think your error messages could do with a bit> > This shoud be a simple problem to fix but it is perplexing me. > > I have the following in my LostFocus event. > > If the condition exists, I'd like the focus to go right back to the > CustomerDirectory textbox. > > > If Not fs.FolderExists(CustomerDirectory.Text) Then > > MsgBox "Bad customer directory, try again", vbExclamation + > vbOKOnly CustomerDirectory.Text = "J:\ML\" ' set directory > to default of work. "Bad customer directory". Naughty, naughty. If you don't behave properly... Might I suggest something along the lines of, "Customer Directory is Invalid." Have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/ error_message_guidelines.asp -- Regards, Michael Cole
VB.net vs VB 6.0
Correct way to get random results with arrays Run IE from VB6 ? Friend Property ques VB6 vs VB.net compatibility Restore Form to Prior State updating multiple records with VBScript and SQL Problem returning DISTINCT records - MS Access Can VB6 & VB.net co-exist How do your read selected values from a BOUND ListBox in VB.Net |
|||||||||||||||||||||||