Forum Moderators: open
I have the following SQL statement:
sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between" & request("fromprice") & " and " & request("toprice") & "%'"
I'm getting the following error:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Location like '%leeds%' and NoBedrooms like '%4%'and Price between1000 and 200000%''.
it seems is getting the requested values but something is missing in the between statement.
Appriciate if anyone can help me.
Thanks
Andreas
sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between" & request("fromprice") & " and " & request("toprice") & "%'"
Just a thought but where is the corresponding ' from your last 4 characters? Also what is the last % used for?
leo
Your post said;
Syntax error (missing operator) in query expression 'Location like '%leeds%' and NoBedrooms like '%4%'and Price between1000 and 200000%''
Would this statement work any better?
Location like '%leeds%' and NoBedrooms like '%4%' and Price between 1000 and 200000
Specifically the first space @ '%4%'and, and the second space @ between1000, plus the fixes le_gber suggested.
- Tony
I try to remove that before and i was getting data missmatch and i remember that the price field in MS Access was text not number, i change that to number and is working fine now.
I post my Final SQL statement may helpful to anyone having similar problems in the future.
sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between " & request("fromprice") & " and " & request("toprice")
Thanks again for your help
Andreas