PDA

Click to See Complete Forum and Search --> : SQL select FROM...WHERE ....txtBox " " ' $ ????


Jackie
Sep 12th, 2000, 04:20 PM
I am TRYING to understand this....

Trying to write a SQL select statement that will
pull data where the database field (Customer Name)
equals the value that the user enters in a text box.
I've seen examples, but I get lost in the strings of
symbols ("'" & " '&").
So, please correct this stament:

"SELECT * FROM Sales WHERE (Customer Name = "txtBox.text")"

Sales = database table
Customer Name = table field
txtBox = name of text box user inputs to

THANKS.

JHausmann
Sep 12th, 2000, 04:29 PM
"SELECT * FROM Sales WHERE Customer Name = '" & trim(txtBox.text) & "'"

Jackie
Sep 12th, 2000, 04:41 PM
Thanks for the quick reply.
I used your example (cut & paste is great!!)
and still get:

Run-time error '3075'
Syntax error (missing operator) in
query expression 'Customer Name = 'Smith"

I imagine the single quote preceeding the Customer
and Smith (the text box data) and the double quote
following Smith are significant...but it's lost on me.

What am I doing wrong?
I am using VB5.

JHausmann
Sep 12th, 2000, 05:19 PM
If you're using Access, then:

"SELECT * FROM Sales WHERE [Customer Name] = '" & trim(txtBox.text) & "'"

Jackie
Sep 13th, 2000, 08:30 AM
THANK YOU THANK YOU THANK YOU.

That worked! I knew it was a simple
symbol issue. Thanks for sharing the
knowledge so generously. This forum is
priceless....and all of those who post
solutions are saints!