运行时,选中option1,输入查询条件后(此信息存在的),弹出“没有找到符合条件的记录!请重新输入查询条件!” 代码如下:Private Sub Command6_Click()
If Option1.Value And Trim(Text17.Text = "") Then
MsgBox "请输入岗位编号!", vbOKOnly + vbInformation, "提示"
Text17.SetFocus
Exit Sub
End If
If Option2.Value And Trim(Text18.Text = "") Then
MsgBox "请输入岗位名称!", vbOKOnly + vbInformation, "提示"
Text18.SetFocus
Exit Sub
End If
If Check1.Value And Combo1.Text = "" Then
MsgBox "请选择部门!", vbOKOnly + vbInformation, "提示"
Combo1.SetFocus
Exit Sub
End If
JDfind_info  '查询信息的事件过程
End Sub
Sub JDfind_info()
Dim sql As String
If Option1.Value Then
If Check1.Value Then
sql = "select * from JD where 岗位编号='&trim(text17.text)&'" & "and 所属部门='&trim(combo1.text)&'"
Else
sql = "select * from JD where 岗位编号='&trim(text17.text)&'"
End If
Else
If Check1.Value Then
sql = "select * from JD where 岗位名称 like '" & "%" & Trim(Text18.Text) & "%" & "'" & "and 所属部门='&trim(combo1.text)&'"
Else
sql = "select * from JD where 岗位名称 like '" & "%" & Trim(Text18.Text) & "%" & "'"
End If
End If
Set rs = New ADODB.Recordset
rs.Open sql, conn, 1, 1
If rs.EOF = False Then
rs.MoveFirst
Set DataGrid2.DataSource = rs
DataGrid2.Refresh
Set Text9.DataSource = rs
Set Text10.DataSource = rs
Set Text11.DataSource = rs
Set Text12.DataSource = rs
Set Text13.DataSource = rs
Set Text14.DataSource = rs
Set Text15.DataSource = rs
Set Text16.DataSource = rs
Else
MsgBox "没有找到符合条件的记录!请重新输入查询条件!", vbOKOnly + vbInformation, "提示"
End If
End Sub