Define a relationship matching the value of these two fields to the two matching fields in your categories table.
MainTable::CategoryField = CategoriesByCatSub::Category AND
MainTable::SubCategoryField = categoriesByCatSub::Subcategory
categoriesByCatSub is a separate table occurrence of the categories table you've listed above.
Double click the relationship line linking these two table occurrences. Enable "Allow creation of records via this relationship" for categoriesByCatSub.
Now this one line script can be used to keep this table up to date:
set field [CategoriesByCatSub::category ; MainTable::CategoryField ]
If the record already exists in the Categories table, nothing visible happens as this step sets categoriesByCatSub::category to a value that it already has. If it does not exist, it creates one with the needed category and subcategory values.
Thank you so much, works a dream! You're some sort of FileMaker God aren't you? Haha.