Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why cant a SetFocus be used in Valid method ?
Message
From
13/07/2002 10:53:05
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00658596
Message ID:
00678394
Views:
20
By design, you can't set focus from a valid event, but you can if you use the lostfocus 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
Rafael Copquin
Treasurer - Microsoft Users Group of Argentina (MUG)
www.mug.org.ar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform