0
votes

I have a subform called MacroAttivitàSub. It has a worksheet layout. The subform recordsource is a query result. On its side I have a text box naled 'text520' which must show the value of the field 'descrizione' of the subform when the user select the desired record row. In the form property tab there is no OnClick event. See image link please. form with no OnClick event There are only 'Enter' and 'Exit'. Why? I tried unsuccesfully this code behind its main form:

Sub MacroAttivitàSub_OnClick()
    Text520.Value = Me!MacroAttivitàSub.Form!descrizione.Value
End Sub

What am I missing?

4

4 Answers

0
votes

The "Form" actually does have a On-Click event. enter image description here

However for what it sounds like you are trying to do I would add the On-Click Event at the detail level and not the form level. That way you can capture the specific record you are clicking on: enter image description here

0
votes

If you want an event that triggers every time the form loads a new record use OnCurrent.

0
votes

If you want to react to events in the subform, you must create an actual form that you insert as subform, instead of the query that you currently have.

A subform control (which you have selected in your screenshot) only has OnEnter and OnExit events. This is by design.

And a query inside a subform control has no events at all (same as a "regular" query).

0
votes

You don't have to write code for this.

First "create an unbound text box" on the main form, then change the control source property of the text box from data tab in properties window to:

[SubForm_Name].[Form]![Control_Name_in_SubForm_to_gather_data]