Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seek on two part key 1

Status
Not open for further replies.

fishman13

Programmer
Jul 8, 2002
73
US
I am trying to do a seek command using a table that has a two part index. The first field is a character length 1 and the second is a character length 5. The index rxinv1 is set to only these two fields. I use this same seach logic with tables with only one condition without a problem, but when I try the code below it never finds the records, even though they exist. What am I doing wrong by adding the second search condition. I am using VFP 5.0

select search_rxinv
set order to tag rxinv1
if seek (thisform.pageframe1.page1.cbo_rectype.displayvalue + ;
thisform.pageframe1.page1.txt_rxqcode.value)
messagebox("key Already Exists",16,"Error")
thisform.requerry_opt()
endif

Thanks
 
I would try trimming the values as such:


if seek (allt(thisform.pageframe1.page1.cbo_rectype.displayvalue) + ;
allt(thisform.pageframe1.page1.txt_rxqcode.value))
messagebox("key Already Exists",16,"Error")
thisform.requerry_opt()
endif


Michael

 
What is the exact value of [thisform.pageframe1.page1.cbo_rectype.displayvalue]? If it has a leading or trailing space it will cause the combined value with [thisform.pageframe1.page1.txt_rxqcode.value] to be incorrect. [thisform.pageframe1.page1.cbo_rectype.displayvalue] must be exactly one character if it represents the first field in your index expression. And [thisform.pageframe1.page1.txt_rxqcode.value] must be no more than five characters. The first one is the most critical, though.

Dana
 
Michael,

Just tried the allt and it still does not work.


I also tried

if seek (thisform.pageframe1.page1.cbo_rectype.displayvalue + ;
thisform.pageframe1.page1.txt_rxqcode.value, ;
search_rxinv, rxinv1)

and get a error rxinv1 is not found.
 
Either use the debugger or a messagebox to display the value that you are trying to seek. Verify it is really 5 characters in lenght (key fields: 1 + 4), and the value you would expect.

Then go to the table and locate for that key combination without an index set. If it's there, and the value you displayed is correct, it could be a corrupt index.



Jim Osieczonek
Delta Business Group, LLC
 
How exactly was the index rxinv1 created? Was it of the form

INDEX ON field1 + field2 TAG rxinv1 ?

If so, then as jimoo says, the value you're searching for must look exactly like "field1 + field2", both in length and content.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top