• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

Count selected records in a continuous form

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
    Loop

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?


0
Dale Fye
Asked:
Dale Fye
1 Solution
 
answer_dudeCommented:
0
 
Dale FyeAuthor Commented:
Precisely what I was looking for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now