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

list all tables that have a certain field in it

Status
Not open for further replies.

trick66

Vendor
Sep 25, 2001
23
0
0
US
I have a production control software that I need to find out which tables have COMP_ID as one if their fields. I know that there are a few tables that have this field name, but I would like to make sure that I get all of them and not miss anything.

Is there a command that can be run in VFP7 if I have the default directory set to the folder where the tables are in.

Thanks in advance.
Rick
 
Hi Rick

If you have an opened database, try this code:


lnTables = ADBOBJECTS(laTables, "Table")

FOR x = 1 TO lnTables
IF !EMPTY(laTables[x])
USE (laTables[x])
FOR y = 1 TO FCOUNT()
IF FIELD(y) = 'COMP_ID'
? laTables[x]
ENDIF
ENDFOR
USE
ENDIF
ENDFOR

Regards,

German
 
Hi Rick,

DIMENSION myarray(1, 1)
=ADIR('myarray', '*.dbf')

FOR i = 1 to ALEN(myarray, 1)
USE (myarray(i, 1))
IF FSIZE('COMP_ID') > 0 && field exists
... do domething
ENDIF
ENDFOR


Jim
 
Thanks all, these are very helpful information.

Rick
 
Is there a command that can be run in VFP7

Field names are in plain text in a dbf so you could use Search from the Windows Start Menu and search for Files or Folders containing text COMP_ID. It's crude and will find any file which has "COMP_ID" as a data entry too but it's quick and takes no programming effort.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top