1,502
社区成员
发帖
与我相关
我的任务
分享
Dim strSQL As String
Dim strCon(7) As String
Dim i As Integer
If Text1.Text <> "" Then
If Check1.Value = 1 Then
strCon(1) = "货物申请表.申请单号 like '%" & Text1.Text & "%'"
Else
strCon(1) = "货物申请表.申请单号='" & Text1.Text & "'"
End If
Else
strCon(1) = ""
End If
If Text2.Text <> "" Then
If Check1.Value = 1 Then
strCon(2) = "货物申请表.运单号 like '%" & Text2.Text & "%'"
Else
strCon(2) = "货物申请表.运单号='" & Text2.Text & "'"
End If
Else
strCon(2) = ""
End If
If Text3.Text <> "" Then
If Check1.Value = 1 Then
strCon(3) = "客户信息表.地址 like '%" & Text3.Text & "%'"
Else
strCon(3) = "客户信息表.地址 ='" & Text3.Text & "'"
End If
Else
strCon(3) = ""
End If
If Text4.Text <> "" Then
If Check1.Value = 1 Then
strCon(4) = "货物申请表.收件人地址 like '%" & Text4.Text & "%'"
Else
strCon(4) = "货物申请表.收件人地址='" & Text4.Text & "'"
End If
Else
strCon(4) = ""
End If
If Text5.Text <> "" Then
If Check1.Value = 1 Then
strCon(5) = "客户信息表.客户姓名 like '%" & Text5.Text & "%'"
Else
strCon(5) = "客户信息表.客户姓名='" & Text5.Text & "'"
End If
Else
strCon(5) = ""
End If
If Text6.Text <> "" Then
If Check1.Value = 1 Then
strCon(6) = "货物申请表.收件人姓名 like '%" & Text6.Text & "%'"
Else
strCon(6) = "货物申请表.收件人姓名='" & Text6.Text & "'"
End If
Else
strCon(6) = ""
End If
If Combo2.Text = "根据申请单号查询" Then
If Text7.Text <> "" Then
strCon(7) = "货物申请表.申请单号 ='" & Text7.Text & "'"
Else
strCon(7) = ""
End If
End If
If Combo1.Text = "根据目的地查询" Then
If Text7.Text <> "" Then
strCon(7) = "货物申请表.收件人地址='" & Text7.Text & "'"
Else
strCon(7) = ""
End If
End If
If Combo2.Text = "根据发件人查询" Then
If Text7.Text <> "" Then
strCon(7) = "客户信息表.客户姓名 ='" & Text7.Text & "'"
Else
strCon(7) = ""
End If
End If
If Combo2.Text = "根据收件人查询" Then
If Text7.Text <> "" Then
strCon(7) = "货物申请表.收件人姓名 ='" & Text7.Text & "'"
Else
strCon(7) = ""
End If
End If
If Combo2.Text = "根据快件状态查询" Then
If Text7.Text <> "" Then
strCon(7) = "在途跟踪信息表.运输状态 ='" & Text7.Text & "'"
Else
strCon(7) = ""
End If
End If
For i = 1 To 7
If strCon(i) <> "" Then
strSQL = strSQL + " and " + strCon(i)
End If
Next
strSQL = "select 货物申请表.申请单号,货物申请表.运单号,客户信息表.地址," _
& " 货物申请表.收件人地址,客户信息表.客户姓名,货物申请表.收件人姓名,在途跟踪信息表.运输状态 from 货物申请表,在途跟踪信息表,客户信息表" _
& " where 货物申请表.申请单号 = 在途跟踪信息表.申请单号 and 货物申请表.运单号 = 在途跟踪信息表.运单号"
Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=物流管理;Initial Catalog=W-L"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Debug.Print strSQL