小弟想在程式執行時依datacombo1.datacombo2欄位之值利用sql指令篩選,動態指定datacombo的row source,row member,listfields和boundcolumn,以列出想要的值,試了好久都無法成功datacombo3都無法列出我要的值(newcmd1.name都是空白),以下是我的程式碼:請各位高手幫我解決這個難題??(軟體vb6.0企業版sp3)
sql = "select 商品編號,商品名稱 from 商品資料 where 廠商編號= "
sql = sql & DataCombo1.Text '& "'"
sql = sql & " and "
sql = sql & "商品編號='"
sql = sql & DataCombo2.Text & "'"
newcmd1.ActiveConnection = DE1.Conn1
newcmd1.CommandType = adCmdText
newcmd1.CommandText = sql
Set rs1 = newcmd1.Execute()
Set DataCombo3.RowSource = newcmd1.Execute(sql)
DataCombo3.RowMember = "newcmd1"
DataCombo3.ListField = rs1.Fields("商品編號").Name
DataCombo3.BoundColumn = rs1.Fields("商品名稱").Name
sql = "select 商品編號,商品名稱 from 商品資料 where 廠商編號= "
sql = sql & DataCombo1.Text '& "'"
sql = sql & " and "
sql = sql & "商品編號='"
sql = sql & DataCombo2.Text & "'"
newcmd1.ActiveConnection = DE1.Conn1
newcmd1.CommandType = adCmdText
newcmd1.CommandText = sql
Set rs1 = newcmd1.Execute()
Set DataCombo3.RowSource = newcmd1.Execute(sql)
DataCombo3.RowMember = newcmd1.name
DataCombo3.ListField = rs1.Fields("商品編號").Name
DataCombo3.BoundColumn = rs1.Fields("商品名稱").Name