If the SQl is a stored query then the text box has to be on an opened form and you refer to it Forms!YourFormName!YourTextBoxName
If you are creating an SQL statement in code then you need to substitute the value instead.
i.e. where tblname.Column = '" & me!YourtextBoxName & "'"
notice the single quotes assuming the Column is Text. If the Column is Numeric then you can omit the single quote.