Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Program Error - Cannot call SetFocus from within ...
Message
From
23/10/1998 10:42:40
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00120667
Message ID:
00149845
Views:
46
>>realize this was discussed last month. but it is relevent to my work today. in my valid i also want to setfocus. a little confused about the "on error". i tried this and still got the vfp error message. do i have to "on error" something to throw away the vfp runtime error?
>>
>>
>>GRID1.COLUMN3.VALID
>>do column4_valid
>>this.column4.setfocus() && get vfp runtime error
>>
>>
>>PROCEDURE COLUMN4_VALID
>>on error && did not say anything else
>>return
>>
>>thanks - brenda
>
>Brenda,
>
>You canno0t call setfoucs form Valid or When at all absolutely ever under any conditions. You need to do the SetFocus call in the Control's LostFocus evetn for the control in the column. Using the Lostfocus event you also need to issue a nodefault command as in;
>
>* Column.Text1.LostFocus
>THIS.Parent.Parent.Columns(1).SetFocus()
>NODEFAULT

Jim -

I just wanted to add my thanks for this tip, which was the answer to my problem. I have a cities combobox which allows user to use incremental search to find existing cities or add a new one by instantiating a data entry form class for cities in the valid. My problem was that my cities form class itself included a setfocus to its control, and was generating the error in the valid event of my combo box. I tried moving my validation code (and instantiation) to the lost focus, which did prevent the valid error, but until I added the NODEFAULT, I was of course losing focus and not validating. Like Brenda, I too have used NODEFAULT before, but it hadn't occured to me to use it in this case. This was a simple, yet valuable piece of info.

Thanks again,

Sylvia
Previous
Reply
Map
View

Click here to load this message in the networking platform