Select Case

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

Hello
I am trying to use the Select Case to do the following, but I get an error
saying "End Select without Select Case" :

Here is my select statement

Dim x As String
x = Form.ActiveControl.Name
For Each chk In Me.Controls
Select Case Left(chk.Name, 2)
Case Is = "ch"
If Not chk.Name = x Then
If Left(chk.Name, 2) = "ch" Then chk.Value = False
End If
Case Is = "ck"
If Not chk.Name = x Then
If Left(chk.Name, 2) = "ck" Then chk.Value = False
chk.Value = False
End If
Case Is = "C_"
If Not chk.Name = x Then
If Left(chk.Name, 2) = "C_" Then chk.Value = False
chk.Value = False
End If
Case Is = "c-"
If Not chk.Name = x Then
If Left(chk.Name, 2) = "c-" Then chk.Value = False
chk.Value = False
End If
Case Else: End Select
End Select
Next

My objective here is to basically do the same as what option buttons do
(only allow 1 selection for each category (ch*, ck*,C_*,c-*))

Any suggestions?
Thank you so much
Terry V
 
You need to remove the statement of "Case Else: End Select

MCP - Access and SQL Serve
----- Terry wrote: ----

Hell
I am trying to use the Select Case to do the following, but I get an erro
saying "End Select without Select Case"

Here is my select statemen

Dim x As Strin
x = Form.ActiveControl.Nam
For Each chk In Me.Control
Select Case Left(chk.Name, 2
Case Is = "ch
If Not chk.Name = x The
If Left(chk.Name, 2) = "ch" Then chk.Value = Fals
End I
Case Is = "ck
If Not chk.Name = x The
If Left(chk.Name, 2) = "ck" Then chk.Value = Fals
chk.Value = Fals
End I
Case Is = "C_
If Not chk.Name = x The
If Left(chk.Name, 2) = "C_" Then chk.Value = Fals
chk.Value = Fals
End I
Case Is = "c-
If Not chk.Name = x The
If Left(chk.Name, 2) = "c-" Then chk.Value = Fals
chk.Value = Fals
End I
Case Else: End Selec
End Selec
Nex

My objective here is to basically do the same as what option buttons d
(only allow 1 selection for each category (ch*, ck*,C_*,c-*)

Any suggestions
Thank you so muc
Terry
 
Terry said:
Hello
I am trying to use the Select Case to do the following, but I get an error
saying "End Select without Select Case" :

Select Case Left(chk.Name, 2)
<...snip...>
Case Else: End Select
End Select

Your extra End Select at the "Case Else" statement is what causes the error.
If you don't have any specific action to take when all other Case conditions
fail, you can omit the Case Else.
 
Back
Top