I am developing a program in access for maintaining test data for other applications. It is a generic program, not for a specific application. The test data is assumed to be stored in database tables. Because my program does not know in advance which tables are part of the application to be stated, it reads the meta data from the application database and creates linked tables for each table. For entering and maintaining the data, I have a form with a subform control. This subform control does not have a predefined source object. By setting the source object property to "table.[linkedtablename]" the subform can be used for data entry. When the user selects another application table from a list, that other table is assigned to the subform. This works pretty good. Now I need to handle events from this subform. Because the subform source object is not a form, this is not obvious. It is no problem to catch events of the subform when they have no arguments. You can write the following code:
Me.subformname.form.oncurrent = "=customoncurrent()"
But how to catch a keydown event? This event is raised with 2 arguments (key code, shift).
I cannot write:
Me.subformname.form.onkeydown = "=customkeydown()"
In runtime, VBA will raise an error that arguments are missing in the event procedure declaration.
I have tried to use the 'withevents' clause but without success. Perhaps I know too little about the possibilities of this clause.
Can this problem be solved and how?
Mark
You have a nice, minimalistic solution going here. But, since you added the requirement for capturing subform events, it became too minimalist!
You could go several ways, but I would suggest this:
This is likely to be less work than other approaches..
BTW don't use WithEvents in form class modules. That is just begging for trouble.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.