vb 复选框多条件查询问题???
PrivateSubcmdInquire_click()各位大哥大姐,求助拉,憋了1周,多条件精确查询也没实现。帮忙看看哪有问题,谢谢!DimmrcAsADODB.Rec...
Private Sub cmdInquire_click()
各位大哥大姐,求助拉,憋了1周,多条件精确查询也没实现。帮忙看看哪有问题,谢谢!
Dim mrc As ADODB.Recordset
txtSQL = "select * from priceinfo1 where "
If ChkProject.Value = Checked Then
If Trim(txtProject.Text) = "" Then
smeg = "项目名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtProject.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "项目名称 like '%" & Trim(txtProject.Text) & "%'"
End If
End If
If ChkSystemName.Value = Checked Then
If Trim(txtSystemName.Text) = "" Then
smeg = "系统名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtSystemName.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "系统部件名称 like '%" & Trim(txtSystemName.Text) & "%'"
End If
End If
If ChkPartsName.Value = Checked Then
If Trim(txtPartsName.Text) = "" Then
smeg = "部件名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtPartsName.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "部件名称 like '%" & Trim(txtPartsName.Text) & "%'"
End If
End If
txtSQL = txtSQL
Set mrc = ExecuteSQL(txtSQL, MsgText)
Set MSHFlexGrid1.DataSource = mrc
End Sub 展开
各位大哥大姐,求助拉,憋了1周,多条件精确查询也没实现。帮忙看看哪有问题,谢谢!
Dim mrc As ADODB.Recordset
txtSQL = "select * from priceinfo1 where "
If ChkProject.Value = Checked Then
If Trim(txtProject.Text) = "" Then
smeg = "项目名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtProject.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "项目名称 like '%" & Trim(txtProject.Text) & "%'"
End If
End If
If ChkSystemName.Value = Checked Then
If Trim(txtSystemName.Text) = "" Then
smeg = "系统名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtSystemName.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "系统部件名称 like '%" & Trim(txtSystemName.Text) & "%'"
End If
End If
If ChkPartsName.Value = Checked Then
If Trim(txtPartsName.Text) = "" Then
smeg = "部件名称不能为空"
MsgBox smeg, vbOKOnly + vbExclamation, "警告"
txtPartsName.SetFocus
Exit Sub
Else
txtSQL = txtSQL & "部件名称 like '%" & Trim(txtPartsName.Text) & "%'"
End If
End If
txtSQL = txtSQL
Set mrc = ExecuteSQL(txtSQL, MsgText)
Set MSHFlexGrid1.DataSource = mrc
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询