In normal programs I always add AGAIN, unless I need to do something 'drastic', meaning when I must use a table EXCLUSIVE. I also always add the ALIAS clause. An example, in a unction to look up a client's address, I may have this line: USE clients ORDER address AGAIN IN 0 ALIAS ClientAddressLookup. Here is a code snippet:
Function FindClientAddress
LPARAMETER cCustId
LOCAL lcAlias,lcReturn
lcAlias=SELECT()
USE clients ORDER custid AGAIN IN 0 ALIAS ClientAddressLookup.
SELECT ClientAddressLookup.
IF SEEK(cCustId)
lcReturn=ClientAddressLookup.address
ELSE
lcReturn=''
ENDIF
USE
SELECT (lcAlias)
RETURN lcReturn
This example is not optimized or anything, it is just to show you the way I always does it.
In a form, I always use the DE, or Data Environment, where you pick the tables, and graphically set the relations. I STRONGLY recomemnd that you use the DE. To get to the DE, you right-click on the form, and select Data Environment. You can even subclass the DE if you have many applications with similar setup.
If you need to ZAP tables regularly, I suggest you use cursors in stead.
>hi,
>
>thank you,
>
>i useto put this code under program as tables1.prg
>
>and i put it at the main form at load (do tables1)
>
>inside the main form i run another forms to add ,delete ....
>
>you mean if i want to use any table i must write again, ex.. use mstr in 0
>
>what about alias not found, or the file is open before...
>
>thanks
>
>m.qasem