设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2068|回复: 6
打印 上一主题 下一主题

[查询] 关于在窗体中查询出结果以后,在报表里面显示的数据可以排序????[含源代码]

[复制链接]
跳转到指定楼层
1#
发表于 2006-9-7 18:49:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如何在窗体中查询出结果以后,在报表里面显示的数据可以排序????

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

请各位高手,给指点一下...最好是有示例说明一下...万分感谢!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2006-9-7 22:30:00 | 只看该作者
继续求助ing...
3#
 楼主| 发表于 2006-9-9 02:56:00 | 只看该作者
沉到海底了....[em06][em06][em06]
4#
发表于 2006-9-9 03:16:00 | 只看该作者
这是个基础问题哦,看看报表设计工具栏上的一个按钮:排序与分组
5#
 楼主| 发表于 2006-9-11 19:46:00 | 只看该作者
谢谢版主的回复:

  关键是:我是根据用户自己选择的排序字段来排序的,这个排序不是固定的某个字段,而是根据用户选择哪个字段,就用哪个字段来排序的..

继续求助ing....
6#
 楼主| 发表于 2006-9-12 16:33:00 | 只看该作者
[em06][em06][em06]
7#
 楼主| 发表于 2006-9-14 20:08:00 | 只看该作者
[em03][em03][em03]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-15 22:51 , Processed in 0.091422 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表