It is, Not sure what type of field it is, but it should work with basic fields. The problem is with other types of fields, without the field key reference ACF does not really know what to return. In the case of get_field('code', $post_id); it should have been returning the text or number that was stored. If you were expecting a post ID this would be a problem.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users