Access VBA教程:Count属性
时 间:2016-03-22 08:31:23
作 者:杨雪 ID:42182 城市:南京
摘 要:应用于窗体和报表对象的 Count属性
正 文:
使用 Count属性可以判断指定集合中的项目个数。Integer 型,可读/写。
expression.Count
expression 必需。返回以上对象之一的表达式。
应用于 AccessObjectProperties、AllDataAccessPages、AllDatabaseDiagrams、AllForms、AllFunctions、AllMacros、AllModules、AllObjects、AllQueries、AllReports、AllStoredProcedures、AllTables、AllViews、Controls、DataAccessPages、FormatConditions、Forms、Modules、Pages、Printers、Properties、References 和 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交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 仓库管理实战课程(11)-人性化操...(04.15)
- 32位的Access软件转化为64...(04.12)
- 【Access高效办公】如何让vb...(04.11)
- 仓库管理实战课程(10)-入库功能...(04.08)
- Access快速开发平台--Fun...(04.07)
- 仓库管理实战课程(9)-开发往来单...(04.02)
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)