Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Preventing duplicate entries
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00118204
Message ID:
00121379
Views:
20
>>I am trying to prevent a user from entering a duplicate number twice into a table. The field is called cmachno. It has an index associated with it which is candidate index. The field is assigned to a text box control in a form. The table is in buffermode=4. The text box's control has code in its valid method which checks for duplicate numbers and it works fine. The problem I am having is when the user goes from the text box control to a tool bar the valid method does not run and therefore does not run the code checking for validation. How can I prevent a user from entering the same number twice into the text box?
>
>Richard,
>
>The problem that you are ahving has to do with when things happen in VFP. A control will update its controlsource upon losing focus. Your problem is that toolbars NEVER get focus, so the textbox doesn;t lose focus.
>
>The solution is to use this type of code in the toolbar;
>
>
>* some button or toolbar method or event
>IF TYPE("_SCREEN.ActiveForm.ActiveControl.ControlSource.Name") = "C"
>   * There is an active control
>   IF PEMSTATUS(_SCREEN.ActiveForm.ActiveControl, "SetFocus",5)
>      * Set focus to the same control to force the valid and lost focus to fire
>      _SCREEN.ActiveForm.ActiveControl.SetFocus()
>   ENDIF
>ENDIF
>* Put the rest of your code here
>
Your code is not forcing the valid before I leave the control on the form. I have placed this code in several places but since, as you said, toolbars NEVER get focus it makes matters more complicated. I am placing the code in a toolbar button's click event now.

The bottom line I cannot find how to get the valid to fire when moving of a form control onto the toolbar. The funny thing is that I have set step on in toolbar button's click event and the valid fires then.

IMHO, VFP is pathetic in this regard. The toolbar is almost useless because of this. Along these lines I have had to use a program called savebuff, written by Michel Fournier, in order to save the value in the control before moving to a tool bar button.

Richard
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform