AOB
Registered User.
- Local time
- Today, 06:00
- Joined
- Sep 26, 2012
- Messages
- 621
Fallover from question on this thread (related but not the same problem...)
I have a continuous subform which lists a set of data from a query. In the header section I have a hidden textbox which holds the ID of the currently selected record. I have a button which updates the value in this header textbox accordingly- nice and simple (this code is in the subform)
So if you click on a record, the ID of that record is held in the textbox in the header. If you click a different record, the ID updates. If you click the same record again (i.e. to "deselect"), it simply clears the header textbox.
In the main form, I have another textbox which is effectively "bound" to the textbox in the subform, i.e. its Control Cource property is as such :
So as I click on records in the subform, the textbox in the main form automatically updates with the ID in the hidden textbox on the subform.
However - I need to be able to detect when that ID changes (i.e. when a user has selected a record in the subform) from the main form. And weirdly I can't seem to do it?
The Change event on the main form textbox doesn't fire when the value is updated via the subform, and the only subform events available to me are Enter and Exit (neither are any good to me as that requires the user to manually move back to a control on the main form after selecting something)
What event on the main form can I use to detect when the selection on the subform has changed?
Thanks!
AOB
I have a continuous subform which lists a set of data from a query. In the header section I have a hidden textbox which holds the ID of the currently selected record. I have a button which updates the value in this header textbox accordingly- nice and simple (this code is in the subform)
Code:
Private Sub cmdSelect_Click()
With Me
.txtSelectedID.Value = IIf(.txtSelectedID.Value = Me.txtID.Value, "", Me.txtID.Value)
End With
End Sub
So if you click on a record, the ID of that record is held in the textbox in the header. If you click a different record, the ID updates. If you click the same record again (i.e. to "deselect"), it simply clears the header textbox.
In the main form, I have another textbox which is effectively "bound" to the textbox in the subform, i.e. its Control Cource property is as such :
=[sfmMySubform].[Form]![txtSelectedID]
So as I click on records in the subform, the textbox in the main form automatically updates with the ID in the hidden textbox on the subform.
However - I need to be able to detect when that ID changes (i.e. when a user has selected a record in the subform) from the main form. And weirdly I can't seem to do it?
The Change event on the main form textbox doesn't fire when the value is updated via the subform, and the only subform events available to me are Enter and Exit (neither are any good to me as that requires the user to manually move back to a control on the main form after selecting something)
What event on the main form can I use to detect when the selection on the subform has changed?
Thanks!
AOB