如何循环通过所有表格? [英] How to cycle thru ALL forms?

查看:64
本文介绍了如何循环通过所有表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下

片段中遇到问题。只有通过

公开表格后才能停止。还有很多比这更好的
。如何修改这个以循环通过

所有表格?

Sub AllOpenForms()

Dim frm As Form

''枚举表格集合。

For For frm In Forms

''打印表格名称。

Debug.Print frm .Name,frm.MenuBar

下一个frm

结束子

Am having trouble with the following
snippet. It stops after only cycling thru
open forms. There are many more than
that. How to modify this to cycle thru
all forms?

Sub AllOpenForms()
Dim frm As Form
'' Enumerate Forms collection.
For Each frm In Forms
'' Print name of form.
Debug.Print frm.Name, frm.MenuBar
Next frm
End Sub

推荐答案

MLH写道:
MLH wrote:

我在以下

片段中遇到问题。只有通过

公开表格后才能停止。还有很多比这更好的
。如何修改这个以循环通过

所有表格?

Sub AllOpenForms()

Dim frm As Form

''枚举表格集合。

For For frm In Forms

''打印表格名称。

Debug.Print frm .Name,frm.MenuBar

下一个frm

结束子
Am having trouble with the following
snippet. It stops after only cycling thru
open forms. There are many more than
that. How to modify this to cycle thru
all forms?

Sub AllOpenForms()
Dim frm As Form
'' Enumerate Forms collection.
For Each frm In Forms
'' Print name of form.
Debug.Print frm.Name, frm.MenuBar
Next frm
End Sub



使用Documents集合。

Use the Documents collection.


我尝试了以下方法FIRST。但它确实没有理解MenuBar,抱怨

找不到方法或数据成员。所以'

为什么我尝试了另一种方法。


Private Sub Command0_Click()

Dim DefaultWorkspace As Workspace

Dim CurrentDatabase As Data

Dim MyContainer As Container,MyDocument As Document,HowManyForms

As Integer

Dim i As整数

设置DefaultWorkspace = DBEngine.Workspaces(0)

设置CurrentDatabase = DefaultWorkspace.Databases(0)

设置MyContainer = CurrentDatabase.Containers( 1)

HowManyForms = MyContainer.Documents.Count

For i = 0 To MyContainer.Documents.Count - 1

设置MyDocument = MyContainer。文件(i)

Debug.Print MyDocument.Name,MyDocument.MenuBar

Next i

End Sub

I tried the following approach FIRST. But it does
not understand the MenuBar, complaining that
the Method or data member not found. So that''s
why I tried the other approach.

Private Sub Command0_Click()
Dim DefaultWorkspace As Workspace
Dim CurrentDatabase As Database
Dim MyContainer As Container, MyDocument As Document, HowManyForms
As Integer
Dim i As Integer
Set DefaultWorkspace = DBEngine.Workspaces(0)
Set CurrentDatabase = DefaultWorkspace.Databases(0)
Set MyContainer = CurrentDatabase.Containers(1)
HowManyForms = MyContainer.Documents.Count
For i = 0 To MyContainer.Documents.Count - 1
Set MyDocument = MyContainer.Documents(i)
Debug.Print MyDocument.Name, MyDocument.MenuBar
Next i
End Sub


问候,试试这个:


Sub checkAllForms()

Dim aob As AccessObject

Dim boolResult As Boolean


每个aob在CurrentProject.AllForms

Debug.Print aob.Name

下一个aob

结束子


此代码将列出您的应用程序中打开的所有表格或关闭


Rich


***通过Developersdex发送 http://www.developersdex.com ***
Greetings, try this:

Sub checkAllForms()
Dim aob As AccessObject
Dim boolResult As Boolean

For Each aob In CurrentProject.AllForms
Debug.Print aob.Name
Next aob
End Sub

this code will list all the forms in your application open or closed

Rich

*** Sent via Developersdex http://www.developersdex.com ***


这篇关于如何循环通过所有表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆