Forum Discussion

Tony2021's avatar
Tony2021
Steel Contributor
Sep 18, 2022

Query with User Input Box

hello Experts,  I have a query with 2 different conditions.  1. I can type in part of a company name in a input message box or 2. I can type in a draw number (tblPmtProposalALL.DDNo) in the next m...
  • Harun24HR's avatar
    Sep 18, 2022

    Tony2021 Try below SQL with IIF() function in where clause. See the attached DB.

    SELECT Table1.ProjID, Table1.DateStart, Table1.DateEnd, Table1.Description, Table1.Rate
    FROM Table1
    WHERE (((Table1.Description) Like IIf(IsNull([Enter Criteria 1]),"*","*" & [Enter Criteria 1] & "*")) AND ((Table1.Rate)=[Enter DD No or enter for all]));

     Here when you will leave first inputbox blank then it will return just * by IIF() function. which will return all records of description field. Otherwise will return *Your Input Text*.

Resources