Select Case Statement 
Author Message
 Select Case Statement

Is it possible to have more than one expression in a select case statement.
I tried this:
Select case IsNull([Company1]) And IsNull([Company2]) And IsNull([Company3])
    Case True And True And True
        .....
    Case True And False And False
        .....
    Case False And False And False
        .....
End Select

But this doesn't work.
How can I use multiple expressions?

Thanks Henri



Sun, 08 Jul 2001 03:00:00 GMT  
 Select Case Statement
Hi, I would change to something like
If IsNull([Company1]) And IsNull([Company2]) And IsNull([Company3]) Then
ElseIf IsNull([Company1]) And Not IsNull([Company2]) And Not
IsNull([Company3]) Then
ElseIf...
I hope this helps you.

Henri skrev i meldingen ...

Quote:
>Is it possible to have more than one expression in a select case statement.
>I tried this:
>Select case IsNull([Company1]) And IsNull([Company2]) And
IsNull([Company3])
>    Case True And True And True
>        .....
>    Case True And False And False
>        .....
>    Case False And False And False
>        .....
>End Select

>But this doesn't work.
>How can I use multiple expressions?

>Thanks Henri



Sun, 08 Jul 2001 03:00:00 GMT  
 Select Case Statement
Select Case can only handle a single value.
Use a construct such as:
------------------------------
Dim bCo1 as Boolean, bCo2 as Boolean, bCo3 as Boolean
bCo1 = IsNull([Company1])
bCo2 = IsNull([Company2])
bCo3 = IsNull([Company3])

If Not (bCo1 Or bCo2 Or bCo3) Then
ElseIf bCo1 and Not (bCo2 or bCo3) Then
ElseIf ...
Else
        ...
End if
------------------------------

BTW, Company1, Company2, and Company3 doesn't look like
a correctly normalized database. Consider taking Company
into a separate related table.

Quote:

> Is it possible to have more than one expression in a select case statement.
> I tried this:
> Select case IsNull([Company1]) And IsNull([Company2]) And IsNull([Company3])
>     Case True And True And True
>         .....
>     Case True And False And False
>         .....
>     Case False And False And False
>         .....
> End Select

> But this doesn't work.
> How can I use multiple expressions?

> Thanks Henri



Mon, 09 Jul 2001 03:00:00 GMT  
 Select Case Statement


Quote:
>Select case IsNull([Company1]) And IsNull([Company2]) And IsNull([Company3])
>    Case True And True And True

  const co1=1
  const co2=2
  const co4=4

  dim coAny as integer
  if isnull([company1]) then coany=co1
  if isnull([company2]) then coany=coAny + co2
  if isnull([company3]) then coany=coAny + co3

  select case coAny
  case co1 ' and not co2 or co3
  '...
  case co1 + co2 ' but not co3
  '...
  etc

  But why not simply normalise the data in the first place and put all
this in the SQL?

Tim F

--



Mon, 09 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Select Case Statement Help

2. Criteria for select case statements

3. Embedded or nested Select Case statements

4. Using a wildcard string comparison in a select case statement

5. Select Case statement is driving me mad!

6. Can you nest Select Case statements?

7. If...Then...Else or Select Case Statement

8. Select Case Statement

9. Select Case Statement

10. Select Case Statement

11. Problem with Expression in a Select Case Statement

12. Select Case Statements

 

 
Powered by phpBB® Forum Software