機房收費系統--組合查詢
阿新 • • 發佈:2019-01-02
Private Sub cmdInquiry_Click()
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
txtSQL = "select * from worklog_Info where (" & cmbField1.Tag & cmbSign1.Text & " '" & txtInquire1.Text & "'"
If cmbMode2.Text <> "" Then
If cmbField2.Text = "" Then
MsgBox "請選擇欄位名!", vbOKOnly + vbExclamation, "警告"
cmbField2.SetFocus
Exit Sub
End If
If cmbSign2.Text = "" Then
MsgBox "請選擇操作符!", vbOKOnly + vbExclamation, "警告"
cmbSign2.SetFocus
Exit Sub
End If
If txtInquire2.Text = "" Then
MsgBox "請輸入要查詢的內容!", vbOKOnly + vbExclamation, "警告"
txtInquire2.SetFocus
Exit Sub
End If
txtSQL = txtSQL & " " & cmbMode2.Tag & " " & cmbField2.Tag & cmbSign2.Text & " '" & txtInquire2.Text & "'"
End If
If cmbMode3.Text <> "" Then
If cmbField3.Text = "" Then
MsgBox "請輸入欄位名!", vbOKOnly + vbExclamation, "警告"
cmbField3.SetFocus
Exit Sub
End If
If cmbSign3.Text = "" Then
MsgBox "a請輸入操作符!", vbOKOnly + vbExclamation, "警告"
cmbSign3.SetFocus
Exit Sub
End If
If txtInquire3.Text = "" Then
MsgBox "請輸入要查詢的內容!", vbOKOnly + vbExclamation, "警告"
txtInquire3.SetFocus
Exit Sub
End If
txtSQL = txtSQL & " " & cmbMode3.Tag & " " & cmbField3.Tag & cmbSign3.Text & " ' " & txtInquire3.Text & " '"
End If
txtSQL = txtSQL & ") order by serial"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.RecordCount = 0 Then
myFlexGrid.Clear
MsgBox "結果集為空!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If