[英]Pass combobox value as a comparison operator in access query?
I have a form with a combobox "cmb1" and a textbox "txt1".我有一个带有 combobox“cmb1”和一个文本框“txt1”的表单。 the combobox can be empty or can hold a comparison operator ">" or "<" or "=" without the quotes while the value of the comparison can be entered in the textbox txt1 as shown in the picture below frm1 and I have this query as shown below qry_employee
combobox 可以为空,也可以包含不带引号的比较运算符“>”、“<”或“=”,而比较值可以输入到文本框 txt1 中,如下图frm1所示,我有这个查询如下图qry_employee
I tried to pass the value from the combobox as a comparison operator and the textbox value in the criteria in the "emplyee_age" field but I couldn't.我试图将 combobox 中的值作为比较运算符传递,并将文本框值传递给“emplyee_age”字段中的标准,但我做不到。 for example
例如
I tried for hours but couldn't get it to work.我尝试了几个小时,但无法正常工作。 All your help is highly appreciated.
非常感谢您的帮助。
after so many trial and error, I have finally got it to work.经过如此多的尝试和错误,我终于让它工作了。 It works perfectly.
它工作得很好。 I will post it here for anyone who might search for the same thing:) here is the sql for the query
我会将它发布在这里,供任何可能搜索相同内容的人使用:) 这是查询的 sql
SELECT tbl_employees.ID, tbl_employees.emplyee_name, tbl_employees.employee_age FROM tbl_employees WHERE (((IIf(IsNull([Forms]![frm1]![cmb1]),True,Eval(([tbl_employees].[employee_age]) & [Forms]![frm1]![cmb1] & [Forms]![frm1]![txt1])))<>False));
Have a great day:)祝你有美好的一天:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.