I haven't really read all the code, and I am feeling somewhat sleepy and I am about to hit the sack, so maybe I am talking nonsense, but I think I see which is the problem. But, I can also be messing things up because of my ignorance about c++
I think the problem is that you are putting the user input into an int. And then evaluating that input (an int) and pretending that the program realized when it is really a number and when it is another thing. Each character the user is inputing goes to the int as a group of chars, so I think that messes up everything. In these cases I think it is better to take the user input and put it into a string and then parse the string first to check if it is a numeric value or if it is anything else. And only if it is a numeric value, I would check if it falls between the values required. I don't know how many parsing functions the string object has in C++, so maybe it is something of a mess to do that. But assuming that the user will input a number is always a dangerous presumption. ALWAYS try the user input as typed by a moronic child hitting the keyboard in anger. Most of the time, you will be right
I got some curiosity at you checking twice in each loop at the condition (target<1 || target>records). Maybe it is a necessity here, maybe there is another way to express that without redundancy. But I can't decide now, as I am really too sleepy.
Well, I hope I could help you, this time

. And if I wasn't of help, then blame my sleep deprivation! (which is odd, because I want' really sleep deprived, today...)