Office中国论坛/Access中国论坛

标题: 在窗体中怎样输入两个日期后可以跳出相应的数据 [打印本页]

作者: 若离ヘ不弃°    时间: 2012-5-22 12:21
标题: 在窗体中怎样输入两个日期后可以跳出相应的数据
[attach]49244[/attach]
作者: todaynew    时间: 2012-5-22 12:28
在控件的更新后事件中写筛选代码即可
作者: 若离ヘ不弃°    时间: 2012-5-22 12:30
todaynew 发表于 2012-5-22 12:28
在控件的更新后事件中写筛选代码即可

具体怎么写能说明下吗,还是菜鸟中的大菜鸟
作者: todaynew    时间: 2012-5-22 12:41
本帖最后由 todaynew 于 2012-5-22 14:01 编辑
若离ヘ不弃° 发表于 2012-5-22 12:30
具体怎么写能说明下吗,还是菜鸟中的大菜鸟


1、写一个子程序
sub Allfiter()
    dim strwh as string
    strwh="True"
    if isnull(me.起始日期.value)=false then
       strwh=strwh & " and 日期>=#" & me.起始日期.value & "#"
    end if
    if isnull(me.截止日期.value)=fasle then
      strwh=strwh & " and 日期<=#" & me.截止日期.value & "#"
    end if
    me.阁下的子窗体控件名称.form.filter=strwh
    me.阁下的子窗体控件名称.form.filteron=true
end sub

2、在控件的更新后时间中调用该子程序
call Allfilter
作者: Henry D. Sy    时间: 2012-5-22 12:57
这样都行吗
作者: Henry D. Sy    时间: 2012-5-22 13:05
  1. Private Sub Command6_Click()
  2.     Dim strWhere As String
  3.     If Not IsNull(Me.Text0) Then
  4.         strWhere = strWhere & " 日期 >=# " & Me.Text0 & "# AND "
  5.     End If
  6.     If Not IsNull(Me.Text2) Then
  7.         strWhere = strWhere & " 日期 <=# " & Me.Text2 & "# AND "
  8.     End If
  9.     If Len(strWhere) <> 0 Then
  10.         strWhere = Left(strWhere, Len(strWhere) - 5)
  11.     End If
  12.     Me.Child4.Form.Filter = strWhere
  13.     Me.Child4.Form.FilterOn = True
  14. End Sub
复制代码

作者: 若离ヘ不弃°    时间: 2012-5-22 16:34
Henry D. Sy 发表于 2012-5-22 13:05

好像不用写这么繁琐的程序啊,在查询设计的日期条件中生成器中 between and 两个文本框就好了
作者: Henry D. Sy    时间: 2012-5-22 16:46
本帖最后由 Henry D. Sy 于 2012-5-22 16:46 编辑
若离ヘ不弃° 发表于 2012-5-22 16:34
好像不用写这么繁琐的程序啊,在查询设计的日期条件中生成器中 between and 两个文本框就好了


我想问你,能用吗?
作者: pq318    时间: 2012-5-22 17:20
between在access,不说了
作者: 520fanren    时间: 2012-5-22 19:31
在控件的更新后事件中
作者: 若离ヘ不弃°    时间: 2012-5-23 12:57
Henry D. Sy 发表于 2012-5-22 16:46
我想问你,能用吗?

[attach]49248[/attach]
作者: Henry D. Sy    时间: 2012-5-23 13:08
若离ヘ不弃° 发表于 2012-5-23 12:57

什么意思
作者: 若离ヘ不弃°    时间: 2012-5-23 13:10
Henry D. Sy 发表于 2012-5-23 13:08
什么意思

就是没写代码啊,日期的筛选条件用窗体中的两个文本框控制啊
作者: Henry D. Sy    时间: 2012-5-23 13:21
方法有很多种,只要你觉得合适就好!
定义查询,更改源对象等等都可以!
作者: 若离ヘ不弃°    时间: 2012-5-23 13:28
Henry D. Sy 发表于 2012-5-23 13:21
方法有很多种,只要你觉得合适就好!
定义查询,更改源对象等等都可以!

嗯,谢谢版主,越简单越好吧,初学的,都是雾水




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3