I've got a form with a subform which is bound to a temporary table. The temporary table contains the result of a pivot, but I'd like users to be able to edit that pivot and then push the changes to the source table.
To do this, I'd like to fire events on AfterInsert
, AfterUpdate
and Delete
so I can act on changes. As I understand it, the subform's form property refers to a temporary datasheet form when the subform is bound to a table. However, I can't get this temporary form to raise any events.
MCVE:
I have a database with a single table, Table1, a single form, Form1, and that form has a single subform control which is unbound.
I have a class, Class1, with the following code:
Private WithEvents subformForm As Access.Form
Public Sub Init(subformControl As Access.SubForm)
Set subformForm = subformControl.Form
subformForm.OnCurrent = "[Event Procedure]"
End Sub
Private Sub subformForm_Current()
MsgBox "Current!"
End Sub
The form, Form1, has the following code:
Private c1 As Class1
Private Sub Form_Load()
sub1.SourceObject = "Table.Table1"
Set c1 = New Class1
c1.Init sub1
End Sub
However, when I move about records, add records, and do whatever in that subform, the subformForm_Current
event never fires.
.SourceObject = "Table.Table1"
the subform shows a table datasheet, and that simply doesn't have these properties. – PurcellsubformForm.OnCurrent = "[Event Procedure]"
doesn't trigger an error, so that property is present. – Sufism.AllowAdditions
, are also present, can be changed and work fine. It's just handling events that's causing problems for me. – SufismOn Current event that fires for each record in the subform
(see here) but not sure its possible to detect from a class module. More discussion also here. This isn't event-related but a handy guide for referring to subforms from elsewhere. – Burgrave