A conditional query

  • Thread starter Thread starter Liat
  • Start date Start date
L

Liat

Hi,

I created a query that takes all the data in a given
range of dates that is selected through a Form in the
following way:
In the Date field, the criteria is :
= Forms!myForm!fromDate and <= Forms!myForm!toDate.

It works fine, however I would like to put a condition to
this criteria. The user can tick or untick the option to
choose a range of dates. If it isn't selected, I would
like the criteria to be empty

I tried to add to the criteria:
IIf([Forms]![F_Menu]![DateV]=True,([tblTviaHaaraha].
[date])>=[Forms]![F_Menu]![fromDateTa] And
([tblTviaHaaraha].[date])<=[Forms]![F_Menu]![ToDateTa],"")
and it said that this is not a right sentance.

How can I do that?

Thanks a lot,
Liat
 
There are many way to accomplish this.
One way it is to have two queries. One is with the where
clause and the other is without. In your form, it will
determined which query to run based on the form fields is
being filled or not.
Hope this helps.
-----Original Message-----
Hi,

I created a query that takes all the data in a given
range of dates that is selected through a Form in the
following way:
In the Date field, the criteria is :
= Forms!myForm!fromDate and <= Forms!myForm!toDate.

It works fine, however I would like to put a condition to
this criteria. The user can tick or untick the option to
choose a range of dates. If it isn't selected, I would
like the criteria to be empty

I tried to add to the criteria:
IIf([Forms]![F_Menu]![DateV]=True,([tblTviaHaaraha].
[date])>=[Forms]![F_Menu]![fromDateTa] And
([tblTviaHaaraha].[date])<=[Forms]![F_Menu]![ToDateTa],"")
and it said that this is not a right sentance.

How can I do that?

Thanks a lot,
Liat

.
 
Thank you very much for your help.

That meens that if this query is one of the sources of a
report, I will need 2 reports, right?

-----Original Message-----
There are many way to accomplish this.
One way it is to have two queries. One is with the where
clause and the other is without. In your form, it will
determined which query to run based on the form fields is
being filled or not.
Hope this helps.
-----Original Message-----
Hi,

I created a query that takes all the data in a given
range of dates that is selected through a Form in the
following way:
In the Date field, the criteria is :
= Forms!myForm!fromDate and <= Forms!myForm!toDate.

It works fine, however I would like to put a condition to
this criteria. The user can tick or untick the option to
choose a range of dates. If it isn't selected, I would
like the criteria to be empty

I tried to add to the criteria:
IIf([Forms]![F_Menu]![DateV]=True,([tblTviaHaaraha].
[date])>=[Forms]![F_Menu]![fromDateTa] And
([tblTviaHaaraha].[date])<=[Forms]![F_Menu]! [ToDateTa],"")
and it said that this is not a right sentance.

How can I do that?

Thanks a lot,
Liat

.
.
 
Once again, there are many way to do it as well.
But to save you time, you can create 2 macro that uses two
different source records (OpenReport Action and you can
give your where clause). In your form, instead of running
the report, run the macro.

Hope this will help.
-----Original Message-----

Thank you very much for your help.

That meens that if this query is one of the sources of a
report, I will need 2 reports, right?

-----Original Message-----
There are many way to accomplish this.
One way it is to have two queries. One is with the where
clause and the other is without. In your form, it will
determined which query to run based on the form fields is
being filled or not.
Hope this helps.
-----Original Message-----
Hi,

I created a query that takes all the data in a given
range of dates that is selected through a Form in the
following way:
In the Date field, the criteria is :
= Forms!myForm!fromDate and <= Forms!myForm!toDate.

It works fine, however I would like to put a condition to
this criteria. The user can tick or untick the option to
choose a range of dates. If it isn't selected, I would
like the criteria to be empty

I tried to add to the criteria:
IIf([Forms]![F_Menu]![DateV]=True,([tblTviaHaaraha].
[date])>=[Forms]![F_Menu]![fromDateTa] And
([tblTviaHaaraha].[date])<=[Forms]![F_Menu]! [ToDateTa],"")
and it said that this is not a right sentance.

How can I do that?

Thanks a lot,
Liat

.
.
.
 
OK, I'll try to do that.

Thanks a lot,
Liat
-----Original Message-----
Once again, there are many way to do it as well.
But to save you time, you can create 2 macro that uses two
different source records (OpenReport Action and you can
give your where clause). In your form, instead of running
the report, run the macro.

Hope this will help.
-----Original Message-----

Thank you very much for your help.

That meens that if this query is one of the sources of a
report, I will need 2 reports, right?

-----Original Message-----
There are many way to accomplish this.
One way it is to have two queries. One is with the where
clause and the other is without. In your form, it will
determined which query to run based on the form fields is
being filled or not.
Hope this helps.

-----Original Message-----
Hi,

I created a query that takes all the data in a given
range of dates that is selected through a Form in the
following way:
In the Date field, the criteria is :
= Forms!myForm!fromDate and <= Forms!myForm!toDate.

It works fine, however I would like to put a
condition
to
this criteria. The user can tick or untick the option to
choose a range of dates. If it isn't selected, I would
like the criteria to be empty

I tried to add to the criteria:
IIf([Forms]![F_Menu]![DateV]=True,([tblTviaHaaraha].
[date])>=[Forms]![F_Menu]![fromDateTa] And
([tblTviaHaaraha].[date])<=[Forms]![F_Menu]! [ToDateTa],"")
and it said that this is not a right sentance.

How can I do that?

Thanks a lot,
Liat

.

.
.
.
 
Back
Top