Thanks for the details. In the WHERE clause, you use standard SQL syntax. So, if you are comparing an integer value, do not use apostrophes, which are for strings. There should be just like: "ItemID = 5" - where the 5 should be the result of the inner expression. So, the macro should look like this:
{%GlobalObjects.CustomTables["customtable.yourtable"].Items.Where("ItemID =" + Field.Value).FirstItem.ReturnValueFieldName#%}
However, the issue here is that the macro in default value is evaluated only once, when the field is rendered, due to performance. So, if you change the value in the other field, it has no effect. In this case it would be better to create a custom form control (portal engine) or form component (MVC/Core development model) which will consists of two fields and you will handle the logic in the code and dynamically load the values as you need. Or, if you will use it as a drop down list and use the macro to fill out the list or, maybe just as a label.