参考代码
Dim cmb As WinForm.ComboBox
cmb = Forms("窗口1").Controls("ComboBox1")
Dim cmb1 As WinForm.ComboBox
cmb1 = Forms("窗口1").Controls("ComboBox2")
Dim cmb2 As WinForm.ComboBox
cmb2 = Forms("窗口1").Controls("ComboBox3")
Dim filter As String = "1=1"
If cmb.Text > "" Then
filter &= " and 序号 = '" & cmb.Text & "'"
End If
If cmb1.Text > "" Then
filter &= " and 班组 = '" & cmb1.Text & "'"
End If
If cmb2.Text > "" Then
filter &= " and 姓名 = '" & cmb2.Text & "'"
End If
cmb.ComboList = DataTables("表A").GetComboListString("序号", filter)
cmb1.ComboList = DataTables("表A").GetComboListString("班组", filter)
cmb2.ComboList = DataTables("表A").GetComboListString("姓名", filter)
If cmb.ComboList.Split("|").length = 1 Then
cmb.text = cmb.ComboList
End If
If cmb1.ComboList.Split("|").length = 1 Then
cmb1.text = cmb1.ComboList
End If
If cmb2.ComboList.Split("|").length = 1 Then
cmb2.text = cmb2.ComboList
End If