Good Day everyone! The first image is the data in my database..
As you can see in the first image, there are two (2) president in the "position" column. When I generate it in the comboBox (see second image in which I put circle) it will only show one (1) name, and the other name won't show. How can I fix this? I don't know where did I got wrong with my code.
Here's my code:
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim tabStatus As Boolean = False
Dim tabPage As New TabPage()
Dim x, maxrows As Integer '\\\\\\
Dim pos_name, can_lname, can_fname, can_mi As String '\\\\\
With tabPage
.Name = Me.cboPosition.Text
.Text = Me.cboPosition.Text
.BorderStyle = BorderStyle.Fixed3D
End With
With tabControl
.Location = New Point(12, 64)
.Size = New System.Drawing.Size(975, 535)
End With
For Each TAB As TabPage In tabControl.TabPages
If cboPosition.Text = TAB.Text Then
tabStatus = True
Exit For
End If
Next
If tabStatus = False Then
SetUp = ElectionSetUpForm
maxrows = dsAdmin.Tables("tblcandidates").Rows.Count '\\
For x = 0 To (maxrows - 1) '\\
pos_name = dsAdmin.Tables("tblcandidates").Rows(x).Item("Position") '\\
can_lname = dsAdmin.Tables("tblcandidates").Rows(x).Item("LastName") '\\
can_fname = dsAdmin.Tables("tblcandidates").Rows(x).Item("FirstName") '\\
can_mi = dsAdmin.Tables("tblcandidates").Rows(x).Item("MiddleName") '\\
If Me.cboPosition.Text = pos_name Then '\\
lbel.Text = can_lname & ", " & can_fname & " " & can_mi
SetUp.Controls.Add(lbel)
End If '\\
Next '\\
tabControl.TabPages.Add(tabPage)
SetUp.Controls.Add(tabControl)
Else
MsgBox(Me.cboPosition.Text & " is already in the list...", MsgBoxStyle.Critical, "...")
End If
End Sub