I have a form in which users may search for a module based on a number of criteria including three check boxes (indicating which processes have been completed) as well as a text box for the user to type in the module number.
I would like to make a query return all values that match the indicated check boxes when the text box is blank, but return ONLY the indicated module number when the text box has text in it.
I know I can use a UNION query to display both (check box query results and the text box result), but for ease of use it would be convenient if only the single value were displayed when the text box is filled in. Or I could simply include all the criteria, but then it would only return the typed in record if the check boxes are also set correctly.
I have tried using a query in which the criteria for the module number is set to the text box (with a ... OR [txtModuleNum] Is Null included so it is ignored if nothing is typed) and using an If statement to control whether or not the check box is evaluated, but I can't seem to get the syntax right. My code is:
Any help would be greatly appreciated.
Thanks in advance!
I would like to make a query return all values that match the indicated check boxes when the text box is blank, but return ONLY the indicated module number when the text box has text in it.
I know I can use a UNION query to display both (check box query results and the text box result), but for ease of use it would be convenient if only the single value were displayed when the text box is filled in. Or I could simply include all the criteria, but then it would only return the typed in record if the check boxes are also set correctly.
I have tried using a query in which the criteria for the module number is set to the text box (with a ... OR [txtModuleNum] Is Null included so it is ignored if nothing is typed) and using an If statement to control whether or not the check box is evaluated, but I can't seem to get the syntax right. My code is:
Code:
SELECT tblModules.ModuleNum, tblModules.Usedinpdm, tblModules.UsedInCATIA FROM tblModules WHERE (((tblModules.ModuleNum)=[Forms]![frmModSearch]![tbModNumDELETE] Or [Forms]![frmModSearch]![tbModNumDELETE] Is Null) AND IFF(Len([Forms]![frmModSearch]![tbModNumDELETE])=0, ((tblModules.Usedinpdm)=[Forms]![frmModSearch]![CheckUpdateUsedInPDM])), Is Null);
Thanks in advance!
Comment