I posted an answer for a user’s question and he indicated he was going to try my solution. After some time he had not indicated whether or not it worked. I commented to ask if it worked or did he encounter a problem. His reply was that he was actually looking for the answer to a different question which he did not post. He also did not edit his original question. Is there any action I can or should take?
My opinion for this situation:
Leave a comment on the question to the effect of "please open a new/separate Question with your actual question".
Flag (or, if you have the Close Privilege, Vote to Close) the question as "Off-topic: problem went away on its own".
I agree with Jeff that the OP should be encouraged to ask a new question.
If the OP edited the question in such a way that your answer is invalidated, see Exit strategies for “chameleon questions” and OP edited question substantially after answer(s) were posted, as cited in the comment by Scott.
But, if the OP left the question alone, and only commented that they were looking for something else, or if they edited the question to add qualifying details, and you have posted a correct answer to the (original) question, it’s not necessarily appropriate to flag/close the question as “problem went away”. See What to do when a user changes their question using details provided by an answer?, which discusses this question, which does not appear to have gone away on its own. (The “Unclear” and “Too broad” options remain.)