In FileMaker Pro 14, using a script, how do I find the total number of fields in a given table?
The calculation you could use would utilize both the "FieldNames" and the "ValueCount" function and would look something like...
ValueCount ( FieldNames ( "NameOfFile" ; "NameOfLayout" ) )
Where / How you decide to use this in your script is up to you. But it could be used anywhere a calculation is accepted - like an IF statement or a custom dialog or...
The NameOfLayout parameter, if left blank, will return the number of fields on the current layout (when the script is run)
You can check the online help for more information on both of the functions mentioned above.
That counts the number of fields on a layout. might not be all the fields in the table or there could even bevfields from more than one table on your layout.
Perhaps using valuecount on:
ExecuteSQL ( “SELECT * FROM FileMaker_Fields WHERE TableName=?” ; “” ; “” ; PutTableNameHere )
Love the FieldNames design function.
It's great for the named Layout.
OTOH, the ExecuteSQL() function has a fews special 'keywords'.
"SELECT * FROM FILEMAKER_FIELDS", for example, returns a list with these columns:
We can narrow down with the query:
[ query = " SELECT FIELDNAME
WHERE TABLENAME = ? "
; result = ExecuteSQL ( query ; "" ; "" ; "table_occurrence_name" )
This returns only the one column and specifies the Table Occurrence from which to draw the names. This is layout independent. And since the returned list is return-separted, the ValueCount() is perfect to get the needed information!
More information on these special keywords with ExecuteSQL():
1 of 1 people found this helpful
Thanks to all that replied!!
I went with the example below:
FieldNames ( "Customers" ; "" ) returns a list of all the fields in the default table of the Customers database file.
This appears to give me what I am looking for.
Yes, I do know about Manage Database window and the information it displays. I am importing a table from a remote location (NAS Storage in my office) and I want to check that all the field names match before proceeding with the import.