If you are using VFP7 or above you can use Database events to handle this automatically like this
PROCEDURE dbc_BeforeOpenTable
LPARAMETERS cTableName
if lower(cTableName) == 'customer' and not used('dealer')
use dealer again in 0
endif
Glenn
>Hi
>
>I have a customer table which has an optional link to a dealer table. I want to be able to order the customer table (in a grid) by the dealer name.
>
>I can create an index on the customer with an expression of
>
>IIF(INDEXSEEK(d_key,.T.,"DEALER","D_KEY"),Dealer.name,SPACE(40))
>
>
>but then I have to have the dealer table open every time I want to use the customer table (including in the form designer) While I can do this, it seems messy.
>
>The user needs to be able to select which order they want, most of which are on the customer table. I can create an external index each time I need to use the index but this also seems a bit messy.
>
>Is there a better way???
>
>Regards
>Geoff Scott