G
Guest
I developed the following Visual Basic code from an example but when run I
get a "For Without Next" Error. What does this error mean? What this code
should accomplish is the selecting multiple items from the Available
Categories list and add them to the Selected Categories list.
Private Sub Add_Category_Click()
Dim VaxListCounter As Integer, VaxCurrentCounter As Integer
Dim VaxListItems As Integer, VaxCurrentItems As Integer
Dim ListStr As String, FoundInList As Integer
VaxListItems = [Available Categories].ListCount - 1
VaxCurrentItems = [Selected Categories].ListCount - 1
For VaxListCounter = 0 To VaxListItems
If [Available Categories].Selected(VaxListCounter) = True Then
If IsNull([Selected Categories].RowSource) Then
ListStr = [Available Categories].Column(0, VaxListCounter) & ";"
[Selected Categories].RowSource = ListStr
Else
FoundInList = False
For VaxCurrentCounter = 0 To VaxCurrentItems
If [Selected Categories].Column(0, VaxCurrentCounter) = _
[Available Categories].Column(0, VaxListCounter) Then
FoundInList = True
End If
Next VaxCurrentCounter
If Not FoundInList Then
ListStr = [Selected Categories].RowSource & _
[Available Categories].Column(0, VaxListCounter) & ";"
[Selected Categories].RowSource = ""
[Selected Categories].RowSource = ListStr
End If
End If
End If
get a "For Without Next" Error. What does this error mean? What this code
should accomplish is the selecting multiple items from the Available
Categories list and add them to the Selected Categories list.
Private Sub Add_Category_Click()
Dim VaxListCounter As Integer, VaxCurrentCounter As Integer
Dim VaxListItems As Integer, VaxCurrentItems As Integer
Dim ListStr As String, FoundInList As Integer
VaxListItems = [Available Categories].ListCount - 1
VaxCurrentItems = [Selected Categories].ListCount - 1
For VaxListCounter = 0 To VaxListItems
If [Available Categories].Selected(VaxListCounter) = True Then
If IsNull([Selected Categories].RowSource) Then
ListStr = [Available Categories].Column(0, VaxListCounter) & ";"
[Selected Categories].RowSource = ListStr
Else
FoundInList = False
For VaxCurrentCounter = 0 To VaxCurrentItems
If [Selected Categories].Column(0, VaxCurrentCounter) = _
[Available Categories].Column(0, VaxListCounter) Then
FoundInList = True
End If
Next VaxCurrentCounter
If Not FoundInList Then
ListStr = [Selected Categories].RowSource & _
[Available Categories].Column(0, VaxListCounter) & ";"
[Selected Categories].RowSource = ""
[Selected Categories].RowSource = ListStr
End If
End If
End If