Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
sql = "select * from jjhetong "
If DataCombo1.Text = "" Then
MsgBox "合同名称不能为空", vbOKOnly + vbExclamation, "警告"
DataCombo1.SetFocus
DataCombo1.BackColor = vbBlue
Exit Sub
End If
If Me.Option1.Value = True Then
sql = "select * from jjhetong where contractname = '" & DataCombo1.Text & "'"
End If
If Me.Option2.Value = True Then
sql = "select * from jjhetong"
End If
rs.Open sql, conn
Set DataCombo1.DataSource = rs
rs.Close
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
refreshcbo
End Sub
Private Sub refreshcbo()
Dim sql As String
Dim rs As New ADODB.Recordset
sql = "select contractname from jjhetong "
rs.Open sql, conn
Do Until rs.EOF
DataCombo1.AddItem rs(0)
rs.MoveNext
Loop
End Sub
请高手指点