If the second part words but the first part fails, then it's not valChk that is failing since you use it identically in both parts.
The failure must be with your variable ENT but your code snippets don't tell me what value is in there - it comes from your datatable. I assume, and you assume, that your datatable value is "ENT_OPTED" but have you checked that? The phrasing of your post makes me think that maybe your datatable contains "600123".
Side note, isn't your query circular? You're selecting unique CODE based on the value of CODE.
Update after your edit to your initial post:
OK, so your datatable contains "option". Is that the correct name of the column you wish to query? If so, then maybe your datatable value also contains an invisible linefeed character (your TRIM function won't remove that if it's there). Or maybe your msgbox just happens to wrap the text at that point. Do you see the same thing (the linefeed) if you just put a breakpoint on the script and view the variable? Maybe if you then copy/paste the variable content from the paused script into MS Word and see if it breaks there?
Last edited by BlakeWalker84120; 05-02-2014 at 01:20 PM.
"The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"