Many OR _ conditions

  • Thread starter Thread starter an
  • Start date Start date
A

an

I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an
 
You could use IN to replace some (if not all) of your OR conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code, using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _
 
Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an
-----Original Message-----
You could use IN to replace some (if not all) of your OR conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code, using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.
 
You didn't say that you had that in an IF statement! Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



an said:
Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an
-----Original Message-----
You could use IN to replace some (if not all) of your OR conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code, using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.
 
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an
-----Original Message-----
You didn't say that you had that in an IF statement! Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an
-----Original Message-----
You could use IN to replace some (if not all) of your
OR
conditions.
[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code, using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.


.
 
How about:

Select Case IDParam
Case "1","2","3","n1"
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Case "4","5","6","n2"
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True
Case Else
'What to do if it is something other than those?
End Select



Chris Nebinger

-----Original Message-----
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an
-----Original Message-----
You didn't say that you had that in an IF statement! Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an

-----Original Message-----
You could use IN to replace some (if not all) of your OR
conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code,
using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.


.
.
 
Thanks for your reply.
With your solution, don't appear any error message but the
text boxes don't hide.
Why not?

Thanks.
an
-----Original Message-----
How about:

Select Case IDParam
Case "1","2","3","n1"
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Case "4","5","6","n2"
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True
Case Else
'What to do if it is something other than those?
End Select



Chris Nebinger

-----Original Message-----
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an
-----Original Message-----
You didn't say that you had that in an IF statement! Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an

-----Original Message-----
You could use IN to replace some (if not all) of
your
OR
conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code,
using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
I need to refer about 200 conditions with OR operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.



.
.
.
 
Try stepping through the code. Put a breakpoint (F9) on
the Select Case, then use F8 to step line by line. See
what the code is doing.

Possibly replace the [Unit] with
Me.Unit.Visible or Me.Controls("Unit").Visible



Chris Nebinger
-----Original Message-----
Thanks for your reply.
With your solution, don't appear any error message but the
text boxes don't hide.
Why not?

Thanks.
an
-----Original Message-----
How about:

Select Case IDParam
Case "1","2","3","n1"
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Case "4","5","6","n2"
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True
Case Else
'What to do if it is something other than those?
End Select



Chris Nebinger

-----Original Message-----
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an

-----Original Message-----
You didn't say that you had that in an IF statement!
Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an

-----Original Message-----
You could use IN to replace some (if not all) of your
OR
conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in code,
using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
I need to refer about 200 conditions with OR
operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam] ="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.



.

.
.
.
 
My guess would be that it thinks IDParam isn't one of the values and so it
is going to the Case Else part. Some things to check, are we referring to
fields or controls here? Do the controls and the fields they are bound to
have the same name? If so, try changing the name of the controls by adding a
prefix to it, such as txt for a textbox or cbo for a combo box. This will
give you distinct names to refer to. Place a break point in the code at the
Select Case statement and hold your mouse over IDParam, what is the value?
You do realize that N1 and N2 are just place keepers, not actual values? Are
the lists of values supposed to be even and odd numbers? If so, there is no
need to list them, you could use the Mod function to see if the value is
even or odd, add a check for >0 if you only want positive numbers.

Example
Odd Numbers
Number Mod 2 <> 0

Even Numbers
Number Mod 2 = 0

If you want a range of numbers, the Case statement will accept that also. If
the values are numbers, they shouldn't have quotes around them.

Example
Case 1 To 3
 
Ok!

Many thanks for your ideas.
an.
-----Original Message-----
My guess would be that it thinks IDParam isn't one of the values and so it
is going to the Case Else part. Some things to check, are we referring to
fields or controls here? Do the controls and the fields they are bound to
have the same name? If so, try changing the name of the controls by adding a
prefix to it, such as txt for a textbox or cbo for a combo box. This will
give you distinct names to refer to. Place a break point in the code at the
Select Case statement and hold your mouse over IDParam, what is the value?
You do realize that N1 and N2 are just place keepers, not actual values? Are
the lists of values supposed to be even and odd numbers? If so, there is no
need to list them, you could use the Mod function to see if the value is
even or odd, add a check for >0 if you only want positive numbers.

Example
Odd Numbers
Number Mod 2 <> 0

Even Numbers
Number Mod 2 = 0

If you want a range of numbers, the Case statement will accept that also. If
the values are numbers, they shouldn't have quotes around them.

Example
Case 1 To 3

--
Wayne Morgan
Microsoft Access MVP





.
 
Again, CN

Thanks for your help.
an
-----Original Message-----
Try stepping through the code. Put a breakpoint (F9) on
the Select Case, then use F8 to step line by line. See
what the code is doing.

Possibly replace the [Unit] with
Me.Unit.Visible or Me.Controls("Unit").Visible



Chris Nebinger
-----Original Message-----
Thanks for your reply.
With your solution, don't appear any error message but the
text boxes don't hide.
Why not?

Thanks.
an
-----Original Message-----
How about:

Select Case IDParam
Case "1","2","3","n1"
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Case "4","5","6","n2"
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True
Case Else
'What to do if it is something other than those?
End Select



Chris Nebinger


-----Original Message-----
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an

-----Original Message-----
You didn't say that you had that in an IF statement!
Perhaps you'd better
step back and show more of your code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
Thanks for you reply.

When I changed to

If [IdParam] In ("1", "2", "6") then

Appear the msg

Compile error:
Expected: Then or GoTo
Why?

Many Thanks.
an

-----Original Message-----
You could use IN to replace some (if not all) of your
OR
conditions.

[IdParam] IN ("1", "6", "n")

is the same as

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam]="n"


On the other hand, if you're building this SQL in
code,
using something
like:

strSQL = "SELECT ..." & _
"FROM ..." & _
"WHERE ..." & _
"OR ..." & _
etc.

You can always break it into smaller sections:

strSQL = "SELECT ..." & _
"FROM ..."
strSQL = strSQL & "WHERE ..." & _
"OR ..." & _

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



message
I need to refer about 200 conditions with OR
operator in
code to, hide or show, Text boxes.
When I try it, with

[IdParam]="1" Or [IdParam]="6" Or ... [IdParam] ="n"

appear the next message error:

"Too many line continuation"

How is possible to pass this situation, please.
Thanks in advance.
an


.



.

.

.
.
.
 
By the way, note simple Coding point as well as complex coding point:


complex: IN operator can be used in VBA if you really need it:
---------------------------------------_
If [IdParam] IN ("1", "2", "3", "n1") Then

could be

If eval([IdParam] & " IN (""1"", ""2"", ""3"",""n1"")") then
----------------------------------------

simple: problem with If statement:
----------------------------------------
Else
eval([IdParam] & " IN (""4"", ""5"",""n2"")") then

should have been

ElseIf eval([IdParam] & " IN (""4"",""5"",""n2"")") then


(david)

an said:
Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an
 
Many, many thanks too.
an
-----Original Message-----
By the way, note simple Coding point as well as complex coding point:


complex: IN operator can be used in VBA if you really need it:
---------------------------------------_
If [IdParam] IN ("1", "2", "3", "n1") Then

could be

If eval([IdParam] & " IN (""1"", ""2"", ""3"",""n1"")") then
----------------------------------------

simple: problem with If statement:
----------------------------------------
Else
eval([IdParam] & " IN (""4"", ""5"",""n2"")") then

should have been

ElseIf eval([IdParam] & " IN (""4"",""5"",""n2"")") then


(david)

Sorry.

I have a F_Form with:

Private Sub Form_Current()

If [IdParam] IN ("1", "2", "3", "n1") Then
[Value].Visible = True
[Unit].Visible = True
[Veloc].Visible = False
Else
[IdParam] IN ("4", "5", "n2") Then
[Value].Visible = False
[Unit].Visible = False
[Veloc].Visible = True

End if
End Sub

Thanks
an


.
 
Back
Top