Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Preventing duplicate entries
Message
From
16/07/1998 21:07:53
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00118204
Message ID:
00118419
Views:
14
>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?



Hey, there are two basic tasks you would do:

1) Inform user that the Key is Duplicated
2) On Error Handler, if error_no is 1884, Duplicate Key,
set Tablerevert() to avoid crash on system!

Of cos, if you can search again before update, if found it,
tablerevert(), prompt user record exist, and locate the OLD Record.

In my view, I only put the code just on next gotfocus control but not in
Valid nor lostfocus procedure because it seem fail to gotfocus on same control
in lostfocus proc. and Valid event return .F. need user press space is very
inconvient.

Moreover, if you have set Keypress to do further tasks, such as add next record,
you need to do the check more carefully, I ve wasted much time on grid for this!

Good Luck! ~_^
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform