General information
Category:
Coding, syntax & commands
Rafael, thanks for your reply
>By design, you can't set focus from a valid event, but you can if you use the lostfocus event.
>
But what is the design reason for this... why cant you set focus from a valid event ?
>Example
>
>text1.valid
>***********
>
>local cAcct
>cAcct = this.value
>
>if seek(cAcct,"customers","account")
> return 1
>else
> this.value = ""
> messagebox("Account not found",16,"ERROR")
> return 0
>endif
>
>text1.lostfocus
>***************
>
>thisform.text2.setfocus
>
>
>In addition, you could add a property to the textbox text1 in its init event and give it a value,depending on whether your valid condition is met, as:
>
>text1.init
>**********
>
>this.addproperty("nCondition",0)
>
>text1.valid
>***********
>
>do case
> case (firstcondition) = .t.
> this.nCondition = 1
> return 1
> case (secondcondition) = .t.
> this.nCondition = 2
> return 1
> etc
> otherwise
> ** (error message)
> return 0
>endcase
>
>text1.lostfocus
>****************
>
>do case
> case this.nCondition = 1
> thisform.text2.setfocus
> case this.nCondition = 2
> thisform.text3.setfocus
> etc
>endcase
>
>As you can see, all you have to do is use your lostfocus event to set focus wherever you want
>
>Hope it helps
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only