Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SEEK Always Finds the Data!
Message
De
30/01/2007 09:23:38
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01190437
Message ID:
01190443
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Gang!
>
>A weird one today!
>
>I was adding a form to a system that is in the field.
>
>This form was designed to be as similar as the other forms already in the system (I inherited the system).
>
>Now, the form uses the Default Data Session with CURSORSETPROP("Buffering",5,"PSE_drug").
>
>The data is bound to the controls through setting the controlsources in the INIT of the form.
>
>Now, this one text control, called txtUPCNDC is bound to PSE_drug.upc_ndc and the PSE_drug table has an index on this field (index is UPC_NDC). The table is a FREE table.
>
>When you press ADD to add a new record, the 1st thing it does is add a BLANK record which is bound to the controls (so we have blank values in the controls).
>
>Now the user can ENTER values into the blank record.
>
>Now, when you SAVE the record, I wanted to make sure that you check the UPCNDC value and make sure it WAS NOT already in the PSE_drug table index.
>
>So, the code calls this code....
>
>
>IF Thisform.m_seek(UPPER(.txtUPCNDC.value),"PSE_drug","UPC_NDC",0) && Exact is OFF
>     lnAnswer = MESSAGEBOX('Duplicate UPC/NDC Number' + CHR(13) + CHR(13)+ "This record   will NOT be saved." + CHR(13) + CHR(13) + "You must input a different (unique) UPC/NDC value to save.",0,"Missing Critical Value")
>     RETURN
>ENDIF			
>
>
>which calls this code in the method of the form...
>
>
>LPARAMETERS txItem,tcTable,tcOrder,tlExact
>LOCAL lcOldExact,llRetVal
>
>lcOldExact = SET("EXACT")
>
>IF TYPE("tlExact") = "N"
>	DO CASE
>		CASE tlExact = 0
>			SET EXACT OFF
>		CASE tlExact = 1
>			SET EXACT ON
>	ENDCASE
>ENDIF
>
>IF !EMPTY(tcOrder)
>	IF SEEK(txItem,tcTable,tcOrder)
>		llRetVal = .T.
>	ELSE
>		llRetVal = .F.
>	ENDIF
>ELSE
>	IF SEEK(txItem,tcTable)
>		llRetVal = .T.
>	ELSE
>		llRetVal = .F.
>	ENDIF
>ENDIF
>
>SET EXACT &lcOldExact
>
>RETURN llRetVal
>
>
>This is BEFORE that record is saved.
>
>The problem is, the SEEK ALWAYS comes out TRUE, even if I input total garbage in the text control. Yet, when I try the same thing by hand by just opening up the table and index and doing the SEEK(), it comes out FALSE when it ought to, and TRUE when it should.
>
>And ideas? A Buffering problem I've overlooked. Basic knowledge that I've overlooked in trying to get too fancy?

Use a view/cursor/cursoradapter for the data entry. Seek against the main table and the record will not be found. Tableupdate from the view/cursor to put the record into the table.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform