Access VBA教程:Count属性-杨雪
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


Access VBA教程:Count属性

发表时间:2016/3/22 8:31:23 评论(0) 浏览(10298)  评论 | 加入收藏 | 复制
   
摘 要:应用于窗体和报表对象的 Count属性
正 文:


使用 Count属性可以判断指定集合中的项目个数。Integer 型,可读/写。

expression.Count

expression   必需。返回以上对象之一的表达式。

应用于 AccessObjectPropertiesAllDataAccessPagesAllDatabaseDiagramsAllFormsAllFunctionsAllMacrosAllModulesAllObjectsAllQueriesAllReportsAllStoredProceduresAllTablesAllViewsControlsDataAccessPagesFormatConditionsFormsModulesPagesPrintersPropertiesReferences Reports对象的 Count属性

使用 Count属性可以判断指定集合中的项目个数。Long 型,只读。

expression.Count

expression   必需。返回以上对象之一的表达式。

设置

Count属性设置是整型值,且在所有视图中都是只读的。

可以使用Visual Basic 确定对象的 Count属性。

说明

例如,如果要确定当前打开的窗体个数或数据库中现有的窗体个数,则可以使用以下代码:


' Determine the number of open forms.
forms.count
' Determine the number of forms (open or closed)
' in the current database.
currentproject.allforms.count

VBA示例

以下示例使用 Count属性控制循环,该循环用于打印所有打开的窗体及其控件的信息。


Sub Print_Form_Controls()
    Dim frm As Form, intI As Integer
    Dim intJ As Integer
    Dim intControls As Integer, intForms As Integer
    intForms = Forms.Count        ' Number of open forms.
    If intForms > 0 Then
        For intI = 0 To intForms - 1
            Set frm = Forms(intI)
            Debug.Print frm.Name
            intControls = frm.Count
            If intControls > 0 Then
                For intJ = 0 To intControls - 1
                    Debug.Print vbTab; frm(intJ).Name
                Next intJ
            Else
                Debug.Print vbTab; "(no controls)"
            End If
        Next intI
    Else
        MsgBox "No open forms.", vbExclamation, "Form Controls"
    End If
End Sub


截图:



Access软件网交流QQ群(群号:198465573)
 
 相关文章
【access入门】聚合函数的示例\聚合函数应用举例,Sum合计\...  【麥田  2012/3/25】
count(1)与count(*)的区别  【宏鹏  2012/12/26】
【Access入门】获取列表框里面数据行数的示例,ListCoun...  【麥田  2013/1/28】
通过TableDef对象的RecordCount属性获取表的总记录...  【金宇  2013/3/11】
【Access DCount示例】模糊统计表中指定值的记录数示例\...  【麥田  2014/4/28】
常见问答
技术分类
相关资源
文章搜索
关于作者

杨雪

文章分类

文章存档

友情链接