问题
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
How can I achieve this?
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.
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.
回答1:
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.
来源:https://stackoverflow.com/questions/49275559/run-vba-for-each-record-in-a-form