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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET RELATION woes 1

Status
Not open for further replies.

DocBus

IS-IT--Management
May 26, 2005
13
NL
Dear All,

Thanks for all the previous help! It has brought me 6 months further in the research we are doing!

My problem in VFP9

I have two tables (A an B). Both contain similar data and have excactly the same structure. Only difference between them is Table B contains newer added records (that is records which are not in table A, but all all records from A are in B).

Both tables are index like this:

Code:
Index on Alltrim(PRAKCODE)+STR(patcode) Tag Joincode

When I set relation into Table B from A (therefore A is master table):

Code:
 SET RELATION TO ALLTRIM(prakcode)+STR(patcode) INTO A

it works fine and the tables are linked. HOWEVER, when I set the relation From B into A (therfore the newer table B is the Master) it doesn't work. I have scoured the helpfile and internet for reasons on this but cannot find an answer. I suspect it is because the newer table has more records. Can anyone help me else I need to resort to writing Large SQL queries to update the table in stead of REPLACE command
 

DocBus,

A possible reason for this is that your index key is variable length -- because of the ALLTRIM(). VFP doesn't like that, and will pad out the keys, so comparisons won't work as you expect. I suggest you try removing the ALLTRIM() and seeing of that cures the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

Thanks for the reply! I tried the key without the alltrim and that didn't work at all. Thats why i added the alltrim. I tried it again - and viola - it works!! Thanks so much.

I think that the problem lies in the variable Prakcode, it is not of a fixed length.

Anyway - thanks!!!!

Cobus
 
Make sure the PrakCode field has the same length in the two tables. If that's not possible, use PADR() in the index expression for the table where PrakCode is shorter to pad it out to the length of the longer one.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top