|
-
Jul 10th, 2000, 10:38 AM
#1
Thread Starter
Addicted Member
When using a text field with a where statement I get "Invalid Column name" WHY?
SQL = "SELECT * FROM Employees where LastName = KING"
rs.Open SQL, dcnNWind, adOpenForwardOnly, adLockReadOnly
Using a number field everything is fine!
SQL = "SELECT * FROM Employees where Employee_ID = 7"
rs.Open SQL, dcnNWind, adOpenForwardOnly, adLockReadOnly
Thanx
-
Jul 10th, 2000, 10:43 AM
#2
Thread Starter
Addicted Member
Using this works
strTest = "King"
SQL = "SELECT * FROM Employees where LastName ='" & strTest & " '"
rs.Open SQL, dcnNWind, adOpenForwardOnly, adLockReadOnly
-
Jul 10th, 2000, 11:18 AM
#3
Guru
you weren't putting single quotes around your criteria:
this
SQL = "SELECT * FROM Employees where LastName = KING"
should have been this
SQL = "SELECT * FROM Employees where LastName = 'KING'"
You properly did that in your second reply, but you might want to lose the space at the end
...'" & strTest & " '"
should be
...'" & strTest & "'"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|