I'm trying to make a form that can be used to query so that the user doesn't have to go in an write up a query in design view. On my form I have text boxes txtBegDate and txtEndDate and AnesNum. I want the form to find all the rows in the table where the field Date is between the two values entered by the user. In my Qry, frmQry, I included several fields including Date. For the criteria of Date in the query design view I included the code
IIf(IsNull([Forms]![frmQry]![txtBeginDate])," " , Between [Forms]![frmQry]![txtBeginDate] And [Forms]![frmQry]![txtEndDate])
What I was trying to do is if the dates are null then i don't want there to be any criteria used in the search but if a beginning date and an ending date are entered then I want them to be used in the criteria.
Any ideas? Am I writing the code wrong or am I going about this the wrong way and should be using a different method?
IIf(IsNull([Forms]![frmQry]![txtBeginDate])," " , Between [Forms]![frmQry]![txtBeginDate] And [Forms]![frmQry]![txtEndDate])
What I was trying to do is if the dates are null then i don't want there to be any criteria used in the search but if a beginning date and an ending date are entered then I want them to be used in the criteria.
Any ideas? Am I writing the code wrong or am I going about this the wrong way and should be using a different method?