This function will get a field name of a field given its location within the database. If the location is -1 it will default to the last field name.
I have updated the script, it now uses 0 to find the last entry and negative numbers to find the field name starting from the right.