I need some help; I cannot see what I am doing wrong in the following code which is part of a Form; the code stop at line (Me.Combo0.Column(y, x) = strProj). I am trying to populate second column in a combo box with data from the recordset rsProjWBS. In Advance, Thank you for your help.
Private Sub Command11_Click()
Dim conn As ADODB.Connection
Dim strSql As String
Dim rsProjWBS As ADODB.Recordset
Dim strProj As String
Dim strProj1 As String
Dim x As Long
Dim y As Long
Set conn = CurrentProject.Connection
Set rsProjWBS = New ADODB.Recordset
strSql = "SELECT dbo_PROJECT.proj_short_name, dbo_PROJWBS.wbs_name, dbo_PROJECT.proj_id " & _
"FROM dbo_PROJECT INNER JOIN dbo_PROJWBS ON dbo_PROJECT.proj_id = dbo_PROJWBS.proj_id " & _
"WHERE (((dbo_PROJECT.project_flag)='Y') AND ((dbo_PROJWBS.proj_node_flag)='Y'))" & _
"ORDER BY dbo_PROJECT.proj_short_name;"
Set rsProjWBS = conn.Execute(strSql)
Me.Combo0.RowSource = ""
Me.Combo0.AddItem ("No Project Selected")
x = 0
y = 0
While Not rsProjWBS.EOF
Dim c As Integer
Dim v As Integer
Dim z As String
Dim gp As String
c = 0
gp = " -> "
z = 1
c = Len(rsProjWBS.Fields.Item(1).Value)
v = 20 - c
While z <= v
gp = gp & " "
z = z + 1
Wend
strProj = rsProjWBS.Fields.Item(0).Value
strProj1 = rsProjWBS.Fields.Item(1).Value
Debug.Print strProj
Debug.Print strProj1
rsProjWBS.MoveNext
Me.Combo0.ColumnCount = 2
Me.Combo0.ColumnWidths = "4 cm;4 cm"
Me.Combo0.AddItem ""
Me.Combo0.Column(y, x) = strProj
x = x + 1
Wend
End Sub
Private Sub Command11_Click()
Dim conn As ADODB.Connection
Dim strSql As String
Dim rsProjWBS As ADODB.Recordset
Dim strProj As String
Dim strProj1 As String
Dim x As Long
Dim y As Long
Set conn = CurrentProject.Connection
Set rsProjWBS = New ADODB.Recordset
strSql = "SELECT dbo_PROJECT.proj_short_name, dbo_PROJWBS.wbs_name, dbo_PROJECT.proj_id " & _
"FROM dbo_PROJECT INNER JOIN dbo_PROJWBS ON dbo_PROJECT.proj_id = dbo_PROJWBS.proj_id " & _
"WHERE (((dbo_PROJECT.project_flag)='Y') AND ((dbo_PROJWBS.proj_node_flag)='Y'))" & _
"ORDER BY dbo_PROJECT.proj_short_name;"
Set rsProjWBS = conn.Execute(strSql)
Me.Combo0.RowSource = ""
Me.Combo0.AddItem ("No Project Selected")
x = 0
y = 0
While Not rsProjWBS.EOF
Dim c As Integer
Dim v As Integer
Dim z As String
Dim gp As String
c = 0
gp = " -> "
z = 1
c = Len(rsProjWBS.Fields.Item(1).Value)
v = 20 - c
While z <= v
gp = gp & " "
z = z + 1
Wend
strProj = rsProjWBS.Fields.Item(0).Value
strProj1 = rsProjWBS.Fields.Item(1).Value
Debug.Print strProj
Debug.Print strProj1
rsProjWBS.MoveNext
Me.Combo0.ColumnCount = 2
Me.Combo0.ColumnWidths = "4 cm;4 cm"
Me.Combo0.AddItem ""
Me.Combo0.Column(y, x) = strProj
x = x + 1
Wend
End Sub