Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Query Condition - (Need Multi Condition)


Message #1 by jose.johnson@j... on Mon, 30 Sep 2002 13:54:49 +0900
Dear Friends

I am not sure what I would like to do is possible or not, but I would like
to share with you all
would like to get your expert advice.

I have a data base where one field is called "datWeldDate"

Now what I want to do that I would like to get the data extracted from the
above table
based on two parameters called "dat_From" & "dat_To".  Here I am using the
"Between dat_From and dat_To. It is working fine and no problem.

Now the real thing I want to do is that when the user kept that two
parameters empty
I would like to return the whole records.  So I think the condition will be
Like "*".

I was trying to use the following condition, but it returning an empty
query result set.
Also I did not rcvd any error message.  So I wonder what would be wrong or
how can I do this or can not be?

IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]),Like "*",Between
[Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

I would appreciate your valuable advice on the above.

If it is not at all possible I am going to use two queries out of one will
be used
to check for that "between" one and the other one only for Like "*". Is
this is a correct method/

Best Regards

Johnson

Message #2 by "Gregory Serrano" <SerranoG@m...> on Mon, 30 Sep 2002 13:39:44
Johnson,

<< Also I did not rcvd any error message.  So I wonder what would be wrong 
or how can I do this or can not be?

IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]),Like "*",Between
[Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO]) >>

Try doing this.  This says if IsNull(expression) then no condition at all 
(since there are two commas together with no argument in the middle.
  
   IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), , Between
   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

But if that's not allowed (syntax error), then try this:

   IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), Is Not Null, Between
   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

This works great if all the dates are always filled in; but if you have 
any nulls in the dates, those won't show.  If you know what the earliest 
date is in your records, say 1990, and the other two tries above don't 
work, try this:

   IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), >=1/1/80, Between
   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

Since you know all your dates fall after January 1, 1980 you'll get 
everything.

Greg
Message #3 by "Daniel Bailey" <maxim_ize@h...> on Mon, 30 Sep 2002 17:18:19
Hi Johnson,

Instead of using IsNull use nz(). This will turn a null into a 0. Then you 
can test if nz()=0:

IIf(nz([Forms]![WEC3600-1100]![dat_FROM])=0,Like "*",Between [Forms]!
[WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO]) >>

NULLs cannot be compared or tested for. They are a different type of beast.

Good Luck.

Regards,
Dan

> Johnson,

> << Also I did not rcvd any error message.  So I wonder what would be 
wrong 
o> r how can I do this or can not be?

> IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]),Like "*",Between
[> Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO]) >>

> Try doing this.  This says if IsNull(expression) then no condition at 
all 
(> since there are two commas together with no argument in the middle.
 >  
 >   IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), , Between
 >   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

> But if that's not allowed (syntax error), then try this:

>    IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), Is Not Null, Between
 >   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

> This works great if all the dates are always filled in; but if you have 
a> ny nulls in the dates, those won't show.  If you know what the earliest 
d> ate is in your records, say 1990, and the other two tries above don't 
w> ork, try this:

>    IIf(IsNull([Forms]![WEC3600-1100]![dat_FROM]), >=1/1/80, Between
 >   [Forms]![WEC3600-1100]![dat_FROM] And [Forms]![WEC3600-1100]![dat_TO])

> Since you know all your dates fall after January 1, 1980 you'll get 
e> verything.

> Greg

  Return to Index