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

INDEX ON CHILD TABLE

Status
Not open for further replies.

jlucio

Programmer
Mar 20, 2001
13
MX
Hi!
Here is a clue. In Command Window:

SELECT 2
USE CUSTOMER && Fields custid,custname
INDEX ON CUSTID TAG CUSTID

SELECT 1
USE INVOICES && Fields invid,custid
SET RELATION TO CUSTID INTO CUSTOMER
INDEX ON CUSTOMER.CUSTNAME TAG NAME

BROWSE FIELDS INVID,CUSTID,CUSTOMER.CUSTNAME

All seems work ok., but how can I do this in a form. If I put this in a DATABASE, There is a find error of NOT FOUND CUSTOMER TABLE. How can I drive the DATABASE and the Data Environment?. Besides, when a change is made in customer table, it doesn't update the invoice index.

Thanks
JLucio
 
This kind of index is dangerous, and you found out why: You need to have BOTH tables open any time either table is open, or else the indexes are not updated properly.

I have not tried this style in a DBC situation, but I'd recommend against it; Use SELECT queries with an ORDER BY clause instead, when you need to report on the data in an sorted fashion.
 
As stated above, I highly recommend against cross-indexes. They are highly unstable. All indexes should only be based on fields in the same table.

If you're looking for a list of all invoices sorted by customer name, you can issue a query like this:
[tt]
***********************************************************
SELECT customer.custid,customer.custname,invoices.invid ;
FROM customer INNER JOIN invoices ;
ON customer.custid=invoices.custid ;
ORDER BY custname INTO CURSOR mycursor
[/tt]
Placing your tables into a database would allow you to create an updateable view based on this query, as well.

Hope that helps,

Ian
 
chpicker and Ian:
Thanks for the tip. I'm going to try via SQL. Both of you agree it is not so dangerous
JLucio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top