设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[模块/函数] 这段代码如何做成公用模块?

[复制链接]
跳转到指定楼层
1#
发表于 2005-11-9 00:19:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Dim ctl As Control

    For Each ctl In Me.Controls

        Select Case ctl.ControlType

        Case acTextBox    '是文本框,要清空(锁定的文本框不能赋值)

          If ctl.Locked = False Then ctl.Value = Null

        

        Case acComboBox    '是组合框,也要清空

            ctl.Value = Null

            '其它类型的控件不处理

        End Select

    Next

由于有me. 不知道怎么做成公用模块,高手赐教。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2005-11-9 00:54:00 | 只看该作者
试试:Public Function Cl(Conts As Controls)    Dim ctl As Control

    For Each ctl In Conts

        Select Case ctl.ControlType

        Case acTextBox

          If ctl.Locked = False Then ctl.Value = Null

        Case acComboBox

            ctl.Value = Null

        End Select

    NextEnd Function

调用:Cl Me.Controls
3#
 楼主| 发表于 2005-11-9 18:58:00 | 只看该作者
谢!
4#
发表于 2005-11-9 21:33:00 | 只看该作者
学习
5#
发表于 2006-6-27 01:43:00 | 只看该作者


这段代码又如何做成公用模块?谢谢。(出自“报表.MDB)



Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As Control
Dim intLineMargin As Integer

intLineMargin = 60

For Each CtlDetail In Me.Section(acDetail).Controls
    With CtlDetail
        If CtlDetail.Name <> "Memo" Then
        Me.Line ((.Left + .Width + intLineMargin), 1)-(.Left + .Width + _
intLineMargin, Me.Height)
        End If
    End With
Next
   

    With Me
        Me.Line (1, 1)-Step(.Width, .Height), 1, B
    End With

Set CtlDetail = Nothing

End Sub
6#
发表于 2006-6-27 02:16:00 | 只看该作者
关键是方法,这样的同类问题就需要你自己动手来解决了。
7#
发表于 2006-6-27 17:12:00 | 只看该作者
已成功,调用:Cl Me.Report

可在报表主体及页眉调用。

Public Sub C1(C11 As Report)

Dim CtlDetail As Control
Dim intLineMargin As Integer
intLineMargin = 60
For Each CtlDetail In C11.Section(0).Controls  

    With CtlDetail
         If CtlDetail.Name <> "Memo" Then
             C11.Line ((.Left + .Width + intLineMargin), 1)-(.Left + .Width + intLineMargin, C11.Height)
        End If
    End With
Next
    With C11
        C11.Line (1, 1)-Step(.Width, .Height), 1, B
    End With
Set CtlDetail = Nothing


End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-22 05:28 , Processed in 0.081895 second(s), 31 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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