when can i detect the position of error in hamming code
You can never detect the positions of errors with certainty. 

You can make the assumption that there is at most a single bit error. Under that assumption, if your code is not a valid code, you can find all different data where the hamming code differs from your code in only one bit position; if there is exactly one such data then you know where the error is (under your assumption). 

You can make the assumption that there is at most a double bit error. Under that assumption, if your code is not a valid code, you can find all different data where the hamming code differs from your code in at most two bit positions; if there is exactly one such data then you know where the error or errors are (under your assumption).