VB中怎么用combobox从access数据库中取值
程序的做用是跟据材料牌号和温度取材料的许用应力.我的代码是这样的,为什么不行.PrivateSubForm_Load()DimiAsIntegerAdodc1.Recor...
程序的做用是跟据材料牌号和温度取材料的许用应力.
我的代码是这样的,为什么不行.
Private Sub Form_Load()
Dim i As Integer
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力"
Combo1.Clear
Do While Not Adodc1.Recordset.EOF
Combo1.AddItem Adodc1.Recordset.Fields("材料牌号")
Adodc1.Recordset.MoveNext
Loop
End Sub
Private Sub Combo1_Click()
Combo2.Clear
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力"
Dim i As Integer
For i = 2 To Adodc1.Recordset.Fields.Count - 1
Combo2.AddItem Adodc1.Recordset.Fields(i).Name
Next i
Combo2.Text = Combo2.List(0)
End Sub
Private Sub Combo2_Click()
Dim conditon
conditon = Trim(Combo2.Text)
If Adodc1.Recordset.Fields(conditon).Type = 202 Then
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力 where" & conditon & " = ' " & Combo2.Text & "'"
Else
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力 where" & conditon & " = " & Combo2.Text & ""
End If
Text1.Text = Adodc1.Recordset.Fields("conditon")
End Sub 展开
我的代码是这样的,为什么不行.
Private Sub Form_Load()
Dim i As Integer
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力"
Combo1.Clear
Do While Not Adodc1.Recordset.EOF
Combo1.AddItem Adodc1.Recordset.Fields("材料牌号")
Adodc1.Recordset.MoveNext
Loop
End Sub
Private Sub Combo1_Click()
Combo2.Clear
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力"
Dim i As Integer
For i = 2 To Adodc1.Recordset.Fields.Count - 1
Combo2.AddItem Adodc1.Recordset.Fields(i).Name
Next i
Combo2.Text = Combo2.List(0)
End Sub
Private Sub Combo2_Click()
Dim conditon
conditon = Trim(Combo2.Text)
If Adodc1.Recordset.Fields(conditon).Type = 202 Then
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力 where" & conditon & " = ' " & Combo2.Text & "'"
Else
Adodc1.RecordSource = "select * from 铸造阀门管件用材料的许用应力 where" & conditon & " = " & Combo2.Text & ""
End If
Text1.Text = Adodc1.Recordset.Fields("conditon")
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询