[SalesForce] Validation rule to prevent account name change on opportunity

I am trying to write a validation rule to prevent users from changing Account name on the Opportunity once a value is present in a custom text field on that Opportunity.

If I use ISCHANGED(Account.Name) I get

"Error: The ISCHANGED function cannot reference the Account.Name
field."

and when I try with ISCHANGED(Account) I get

" Error: Field Account does not exist. Check spelling."

Can you please help me with the formula?

Best Answer

if you want to restrict changes to Account field only if the field already has a value, then you can use something like this

AND(
  NOT(ISBLANK(AccountId)),
  ISCHANGED(AccountId)
)

this will check if the Account field has changed and if it already has a value.