Dear Jen,
generally you receive the message F5407 if you have maintained a VAT number in the customer/vendor master record (STCEG), but the used tax code has no entry in field T007A-EGRKZ (EU code = blank).
Entering a VAT number into a document is only relevant for the creation of the EC-Sales list.
So you will continue to get the message F5 407 when you enter a customer/vendor document with a tax code having no entry in field EGRKZ but including VAT registration number.
Best regards,
Vera