I'm trying to determine how many records are selected in a continuous subform.
I have a custom shortcut menu for a form which displays detailed information on the currently selected record. The function that is called by this shortcut menu item is used in several different forms, so it uses the following code to drill down if the active form is a subform.
dim frm as Form
Set frm = Screen.ActiveForm
Do While frm.ActiveControl.ControlType = acSubform
Set frm = frm.ActiveControl.Form
This code works great, unless the user clicks on the record selector rather than clicking in a field on the form. In that case, there is no ActiveControl, and the Do While line generates the error:
#2474: The expression you entered requires the control to be in the active window.
I've figured out that the Form_MouseUp event occurs whenever the user clicks on a record selector, and by putting a line in the mouseup event that sets the focus to one of the controls in that record, it actually prevents the user from selecting multiple records, which resolves my problem.
However, this raised the question in my mind about record selectors. I noticed another post recently that the user wanted to know how many records from a continuous form were being selected in a deletion operation, and the answer related to the BeforeDeleteConfirm event. I also found a post from several years back where jDettman referenced the Access Developers Handbook, but I have not been able to find any code in the version I have on hand that deals with this topic.
I'd like to be able to use the MouseUp event to determine how many records are selected. Any ideas?