Hi
I have an SQL statement I’m using within my VB app, which works fine. I want to modify it to so that some date criteria are met. I can’t seem to get the line to work.
This is the working version without criteria.
RS.Open "SELECT ou_dba.request.request_id, ou_dba.non_part_usage.person_id, ou_dba.request.zippost, ou_dba.place.global_name, ou_dba.non_part_usage.description, ou_dba.non_part_usage.bill_price, ou_dba.req_assign.promised_begin_dt, ou_dba.person.name, ou_dba.person.first_name, ou_dba.request.status, ou_dba.request.action_status FROM ou_dba.request INNER JOIN ou_dba.non_part_usage ON ou_dba.request.request_id = ou_dba.non_part_usage.request_id INNER JOIN ou_dba.req_assign ON ou_dba.request.request_id = ou_dba.req_assign.request_id INNER JOIN ou_dba.place ON ou_dba.request.place_id = ou_dba.place.place_id INNER JOIN ou_dba.person ON ou_dba.req_assign.person_id = ou_dba.person.person_id ORDER BY ou_dba.request.request_id", db, adOpenStatic, adLockOptimistic
This works fine but when I add criteria on the end it all falls apart. DateFrom and DateTo are valid dates as selected via some date pickers.
Here’s the same statement with a WHERE clause. I’ve tried a few variations but without success!
RS.Open "SELECT ou_dba.request.request_id, ou_dba.non_part_usage.person_id, ou_dba.request.zippost, ou_dba.place.global_name, ou_dba.non_part_usage.description, ou_dba.non_part_usage.bill_price, ou_dba.req_assign.promised_begin_dt, ou_dba.person.name, ou_dba.person.first_name, ou_dba.request.status, ou_dba.request.action_status FROM ou_dba.request INNER JOIN ou_dba.non_part_usage ON ou_dba.request.request_id = ou_dba.non_part_usage.request_id INNER JOIN ou_dba.req_assign ON ou_dba.request.request_id = ou_dba.req_assign.request_id INNER JOIN ou_dba.place ON ou_dba.request.place_id = ou_dba.place.place_id INNER JOIN ou_dba.person ON ou_dba.req_assign.person_id = ou_dba.person.person_id WHERE (ou_dba.req_assign.promised_begin_dt > " & DateFrom & ") AND (ou_dba.req_assign.promised_begin_dt < " & DateTo & ")"
Any ideas?
Thanks
Andrew
I have an SQL statement I’m using within my VB app, which works fine. I want to modify it to so that some date criteria are met. I can’t seem to get the line to work.
This is the working version without criteria.
RS.Open "SELECT ou_dba.request.request_id, ou_dba.non_part_usage.person_id, ou_dba.request.zippost, ou_dba.place.global_name, ou_dba.non_part_usage.description, ou_dba.non_part_usage.bill_price, ou_dba.req_assign.promised_begin_dt, ou_dba.person.name, ou_dba.person.first_name, ou_dba.request.status, ou_dba.request.action_status FROM ou_dba.request INNER JOIN ou_dba.non_part_usage ON ou_dba.request.request_id = ou_dba.non_part_usage.request_id INNER JOIN ou_dba.req_assign ON ou_dba.request.request_id = ou_dba.req_assign.request_id INNER JOIN ou_dba.place ON ou_dba.request.place_id = ou_dba.place.place_id INNER JOIN ou_dba.person ON ou_dba.req_assign.person_id = ou_dba.person.person_id ORDER BY ou_dba.request.request_id", db, adOpenStatic, adLockOptimistic
This works fine but when I add criteria on the end it all falls apart. DateFrom and DateTo are valid dates as selected via some date pickers.
Here’s the same statement with a WHERE clause. I’ve tried a few variations but without success!
RS.Open "SELECT ou_dba.request.request_id, ou_dba.non_part_usage.person_id, ou_dba.request.zippost, ou_dba.place.global_name, ou_dba.non_part_usage.description, ou_dba.non_part_usage.bill_price, ou_dba.req_assign.promised_begin_dt, ou_dba.person.name, ou_dba.person.first_name, ou_dba.request.status, ou_dba.request.action_status FROM ou_dba.request INNER JOIN ou_dba.non_part_usage ON ou_dba.request.request_id = ou_dba.non_part_usage.request_id INNER JOIN ou_dba.req_assign ON ou_dba.request.request_id = ou_dba.req_assign.request_id INNER JOIN ou_dba.place ON ou_dba.request.place_id = ou_dba.place.place_id INNER JOIN ou_dba.person ON ou_dba.req_assign.person_id = ou_dba.person.person_id WHERE (ou_dba.req_assign.promised_begin_dt > " & DateFrom & ") AND (ou_dba.req_assign.promised_begin_dt < " & DateTo & ")"
Any ideas?
Thanks
Andrew