|
如何在窗体中查询出结果以后,在报表里面显示的数据可以排序????
Option Compare Database
Dim varStr As String
------------------------------------------
Private Sub btnCount_Click()
Call CountBill
DoCmd.OpenReport "业务财务统计", acViewPreview, varStr
End Sub
-----------------------------------------
Public Sub CountBill()
varStr = "Select Mblno,Hblno,发货人简称,收货人简称,通知人简称,出口年月日,到港日,所属主单号,单据类型,船名 from FindCorps where 系统编号<>0 "
If IsNull(TextStartDate) = False Then
If IsNull(TextStopDate) = False Then
varStr = varStr & " and 出口年月日 Between #" & TextStartDate & "# and #" & TextStopDate & "# "
Else
varStr = varStr & " and 出口年月日=#" & TextStartDate & "#"
End If
Else
If IsNull(TextStopDate) = False Then
varStr = varStr & " and 出口年月日=#" & TextStopDate & "#"
End If
End If
If IsNull(StartDate) And IsNull(StopDate) Then
If StartDate < StopDate Then
MsgBox " 日期选择错误! ", , "提示"
Exit Sub
End If
End If
If IsNull(TextVsl) = False Then
varStr = varStr & " and 船名='" & TextVsl & "'"
End If
If IsNull(Textvoy) = False Then
varStr = varStr & " and 航次='" & Textvoy & "'"
End If
If IsNull(TextShipper) = False Then
varStr = varStr & " and 收货人='" & TextShipper & "' or 通知人='" & TextShipper & "' "
End If
If IsNull(TextConsignee) = False Then
varStr = varStr & " and 发货人名称='" & TextConsignee & "'"
End If
If IsNull(ComboCTNSType) = False Then
If ComboCTNSType = "ALL" Then
varStr = varStr & " and 单据类型<>'MH' and 单据类型<>'COLOAD' "
Else
varStr = varStr & " and 货物类型='" & ComboCTNSType & "'"
End If
End If
If CheckFCL.Value = -1 Then
varStr = varStr & " and IsNull(所属主单号)=false "
End If
If IsNull(TextMasterNo) = False Then
varStr = varStr & " and 工作编号='" & TextMasterNo & "' or 所属主单号='" & TextMasterNo & "'"
End If
If IsNull(FrmFilter) = False Then
Select Case FrmFilter
Case 1 '船名
varStr = varStr & " order by 船名"
Case 2 'hblno
varStr = varStr & " order by HBLNO"
Case 3 'mblno
varStr = varStr & " order by MBLNO"
Case 4 'ETD
varStr = varStr & " order by 出口年月日"
Case 5 '发货人
varStr = varStr & " order by 发货人简称"
Case 6 '收货人
varStr = varStr & " order by 收货人简称"
End Select
End If
MsgBox varStr
End Sub
------------------------------------
以上是我写的代码,但是为什么在报表当中,不能进行排序呢.不管选哪种方法排序..
报表和窗体的数据源都是:表FindCorps
请各位高手,给指点一下...最好是有示例说明一下...万分感谢! |
|