A Sleeve of Oreos
New member
- Local time
- Today, 11:18
- Joined
- Jun 13, 2017
- Messages
- 5
[Solved] Query by Form Criteria Issues
Hi everyone,
I'm relatively new to access, and a new member to this forum.
I have a Query by Form for a database search. I have two date controls on the form, "begin_date" and "end_date". The goal is for the query to return the records between the two user-entered dates. However, if the user omits the end_date, the records after the begin_date should be returned. Likewise, if the user omits the begin_date, all records before the end_date should be returned. Finally, if the user omits both dates, all records should be returned. Is this possible to actually write in one criteria section in the query?
Thus far, I have attempted a few iterations of the above. My current one only returns records when both date entries are omitted (The input dates I've tested were targeted to specifically return records). Below is what I've put in the criteria section.
Like IIf((Nz([Forms]![Database_Search]![Begin_Date_Search])+Nz([Forms]![Database_Search]![End_Date_Search]))=0,"*",IIf(IsNull([Forms]![Database_Search]![End_Date_Search])=True,([Quote_Work_Sheet_Entries].[Quote_Date])>[Forms]![Database_Search]![Begin_Date_Search],IIf(IsNull([Forms]![Database_Search]![Begin_Date_Search])=True,([Quote_Work_Sheet_Entries].[Quote_Date])<[Forms]![Database_Search]![End_Date_Search],([Quote_Work_Sheet_Entries].[Quote_Date])>=[Forms]![Database_Search]![Begin_Date_Search] And ([Quote_Work_Sheet_Entries].[Quote_Date])<=[Forms]![Database_Search]![End_Date_Search])))
In this case [Quote_Date] is the field in the table [Quote_Work_Sheet_Entries] being searched. I would greatly appreciate any help!
Thanks, Andre
Hi everyone,
I'm relatively new to access, and a new member to this forum.
I have a Query by Form for a database search. I have two date controls on the form, "begin_date" and "end_date". The goal is for the query to return the records between the two user-entered dates. However, if the user omits the end_date, the records after the begin_date should be returned. Likewise, if the user omits the begin_date, all records before the end_date should be returned. Finally, if the user omits both dates, all records should be returned. Is this possible to actually write in one criteria section in the query?
Thus far, I have attempted a few iterations of the above. My current one only returns records when both date entries are omitted (The input dates I've tested were targeted to specifically return records). Below is what I've put in the criteria section.
Like IIf((Nz([Forms]![Database_Search]![Begin_Date_Search])+Nz([Forms]![Database_Search]![End_Date_Search]))=0,"*",IIf(IsNull([Forms]![Database_Search]![End_Date_Search])=True,([Quote_Work_Sheet_Entries].[Quote_Date])>[Forms]![Database_Search]![Begin_Date_Search],IIf(IsNull([Forms]![Database_Search]![Begin_Date_Search])=True,([Quote_Work_Sheet_Entries].[Quote_Date])<[Forms]![Database_Search]![End_Date_Search],([Quote_Work_Sheet_Entries].[Quote_Date])>=[Forms]![Database_Search]![Begin_Date_Search] And ([Quote_Work_Sheet_Entries].[Quote_Date])<=[Forms]![Database_Search]![End_Date_Search])))
In this case [Quote_Date] is the field in the table [Quote_Work_Sheet_Entries] being searched. I would greatly appreciate any help!
Thanks, Andre
Last edited: