adding a WHERE to SQL select statment

carlton123

Registered User.
Local time
Today, 07:53
Joined
Mar 18, 2011
Messages
48
I have a SELECT stament which works

Code:
"SELECT Bookings_Table.Booking_Time, Bookings_Table.Num_Slots, Bookings_Table.Booking_Date FROM Bookings_Table ORDER BY Bookings_Table.Booking_Time;"
but when i add the WHERE

Code:
 "SELECT Bookings_Table.Booking_Time, Bookings_Table.Num_Slots, Bookings_Table.Booking_Date FROM Bookings_Table WHERE (((Bookings_Table.Booking_Date)=[TB_CAL_DATE])) ORDER BY Bookings_Table.Booking_Time;"
it doesn't work [TB_CAL_DATE] is a textbox with a Date in it any help would be great thanks
 
You may need date delimiters, which are "#" signs.

Also, depending on where you use this statement, you may need to evaluate the textbox reference outside the string. More specifically, a SQL statement is a string, and if you include the name of a textbox in that string, all you've supplied is the name of the textbox, not the value that the textbox contains. Consider the difference between . . .
Code:
"SELECT * FROM Table WHERE Field1 = NameOfTextbox"
. . . and . . .
Code:
"SELECT * FROM Table WHERE Field1 = " & NameOfTextbox
You can see how the SQL processor will regard these two WHERE clauses very differently.
Hope this helps,
 
tried suggestions struggling with this!
 

Users who are viewing this thread

Back
Top Bottom