Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Seek function LIES!
Message
From
16/12/2003 10:54:22
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Seek function LIES!
Miscellaneous
Thread ID:
00859505
Message ID:
00859505
Views:
64
I have a very simple routine in the valid of a text box. Valid searches for the value entered into the box. If the user is not in add mode, the record is brought up on screen for display. If the user is in add mode and the value is found, an error message is given to prevent duplicate entries. For some reason, this seek message is returning True regardless of the value entered IF, AND ONLY IF, you have previously entered a duplicate. For example, the user enters 'APPLE' and apple is in the table. The key is found and the proper message is returned. The user is returned to the field and now enteres 'BABY'. The seek is performed, the record is found (it's the new record from append blank) but the recno is NOT -1; recno remains on the record number of the original seek! Since recno is NOT -1, the second if below is evaluated as True and we get the message again.
============ field valid code =========================
LOCAL tkey
tkey = this.Value
IF ! EMPTY(tkey)
IF SEEK(Tkey,"AP","chopap") AND RECNO() # -1
IF thisform.r_laddmode
=MESSAGEBOX("This code is already in use.",16,"DUPLICATE CODE NOT ALLOWED")
RETURN .F.
ELSE
thisform.refresh()
ENDIF
ELSE
IF ! thisform.r_laddmode
=MESSAGEBOX("Code was not found.",16,"ENTER ANOTHER CODE")
RETURN .f.
ENDIF
ENDIF
ENDIF
=================================================
Questions:
(1) Why does the record pointer remain on the previously sought record?
and (2) What do I need to change to assure I catch duplicate records correctly on an add?

TIA for your help!
Vicki Combs
Customized software for today AND tomorrow...
Applications and web sites designed, developed and maintained. (MBE)

"Change is inevitable...unless that's changed!
Next
Reply
Map
View

Click here to load this message in the networking platform