为表单中的每个记录运行VBA [英] Run VBA for each record in a form

查看:67
本文介绍了为表单中的每个记录运行VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个表格,该表格连续显示表的每个记录的某些文本框,我希望在每条记录的所有文本框(自动地,不是通过VBA)填充了来自以下数据的数据后执行VBA子程序当前记录.因此理想的执行顺序为:

Given a form which continuously displays certain text boxes for a each record of a table, I'd like a VBA sub to be executed after all text boxes for each record have been (automatically, not via VBA) populated with data from the current record. So the idealized order of execution would be:

fetch next record from table
distribute values into text boxes and draw
execute VBA
fetch next record from table

我该如何实现?

注意:该表单是连续的"(我不知道如何在access-jargon中说这句话),即. e.一次显示所有记录,而不一次显示一个记录,并带有用于前进/后退的按钮.

Note: The form is "continuous" (I don't know how to say this in access-jargon), i. e. displays all records at once, and not one record at a time with buttons for moving forward/backward.

注意2:我要做的是以下几点:我有一个表F,其中包含另一个表T的字段名称.我的表单遍历F的行.对于F中列出的每个字段名称,我想打印出该名称,并构建一个查询,该查询绘制一个直方图,显示该列中T中的数据.

Note 2: What I achieve to do is the following: I have a table F that contains names of fields of another table T. My form iterates through the rows of F. For each field name listed in F, I want to print out the name, and build a query that draws a histogram showing the data from T for that column.

推荐答案

您不能.在Access中,连续形式的控件只有一个实例.控件上的任何操作都会影响对所有记录的控件.

You can't. In continuous forms in Access, controls have only a single instance. Any operation on a control influences that control for all records.

连续记录中的每条记录都没有单独的事件.

There are no separate events per record on a continuous form.

您可以遍历记录,但只能在填充表格之前或之后进行.

You can iterate through the records, but only before or after the form has been populated.

这篇关于为表单中的每个记录运行VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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