Try a break point at this line and then 'step forward' you need to see what sql contains after it executs. Also modify the line to this.
sql = "select [stock code] from stock where [stock code] = " & txt.code
'sql may have txt.code if one exist plus other data, or it may be empty if no txt.code exists, not guaranteed
'then do this (pardon the C++ style)
if(sql == txt.code)
'txt.code exist
else
'txt.code does not exist
endif
Let's act on what we agree on now, and argue later on what we don't.
Black men leave Barbeque alone if Barbeque don't trouble you