G
Guest
I have a user form in which you can pick different time frames. ie "In the
next 30 days"; "In the next 60 days"; "In the next 90 days", and then run the
query to return records that are scheduled in that time frame, etc.
This runs with no errors, however it doesn't return any results either. If
I change the criteria to just "Between Date() And Date()+30" it does show the
records that it's supposed to, but as soon as I add the
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30 days",Between Date()
And Date()+30), I get no results.
Also, if I change the field's criteria to this:
=============================
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30 days",Between
Date() And Date()+30)
=============================
Access automatically changes the criteria to this:
=============================
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+30)
=============================
Very confused as to why this is so. I just want to be able to choose a time
from from the dropdown in the user form, and have the query show results that
fit in that time frame. Any help is appreciated.
Here's what I have right now:
=========================================
SELECT Chart.[Status], Chart.[P#], Chart.TITLE, IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training Date])) AS [Next
Training Date], Format(IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training Date])),"yyyy mm
dd") AS SortOrder
FROM Chart
WHERE (((Chart.[Status])=4) AND ((IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training
Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+30) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 60
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+60) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 90
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+90) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 6
months",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+180)))
ORDER BY Format(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date])),"yyyy mm dd");
=========================================
next 30 days"; "In the next 60 days"; "In the next 90 days", and then run the
query to return records that are scheduled in that time frame, etc.
This runs with no errors, however it doesn't return any results either. If
I change the criteria to just "Between Date() And Date()+30" it does show the
records that it's supposed to, but as soon as I add the
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30 days",Between Date()
And Date()+30), I get no results.
Also, if I change the field's criteria to this:
=============================
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30 days",Between
Date() And Date()+30)
=============================
Access automatically changes the criteria to this:
=============================
IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+30)
=============================
Very confused as to why this is so. I just want to be able to choose a time
from from the dropdown in the user form, and have the query show results that
fit in that time frame. Any help is appreciated.
Here's what I have right now:
=========================================
SELECT Chart.[Status], Chart.[P#], Chart.TITLE, IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training Date])) AS [Next
Training Date], Format(IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training Date])),"yyyy mm
dd") AS SortOrder
FROM Chart
WHERE (((Chart.[Status])=4) AND ((IIf([Training Frequency] Is
Null,Null,DateAdd("m",[Training Frequency],[Last Training
Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 30
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+30) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 60
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+60) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 90
days",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+90) Or
(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training Frequency],[Last
Training Date])))=IIf([Forms]![frmTimeScheduled]![cboTime]="In the next 6
months",(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date]))) Between Date() And Date()+180)))
ORDER BY Format(IIf([Training Frequency] Is Null,Null,DateAdd("m",[Training
Frequency],[Last Training Date])),"yyyy mm dd");
=========================================