Selected records in a continous subform

G

Guest

nIn a continous subform, when a user has selected a single record with the
record selecter, it is possible to tell which record is selected simply by
refering to the subform control name. for example
Form_fMainSubPlanList.PlanID refers to the PlanID of the plan selected in the
plan list.

Question: if the user selects multiple records by clicking the record
selecter, then shift-clicking another record selecter, is there a form object
which allows the programmer to loop through the list of selected records?

Thanks

Fred
 
G

Graham Mandeno

Hi Fred

The SelTop and SelHeight properties of the form give you, respectively, the
record number of the first record selected and the number of records
selected.

Note that this is the record number, not the primary key value.

Using these properties in any meaningful way can be difficult because if you
click on any other control such as a command button, you lose the selection.
One solution is to set the form's KeyPreview property and use the
Form_KeyDown event.

The following example lists the PlanID for each of the selected records when
you press Alt-L:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Integer
If KeyCode = Asc("L") And (Shift And acAltMask) <> 0 Then
With Me.RecordsetClone
.AbsolutePosition = Me.SelTop - 1
For i = 1 To Me.SelHeight
Debug.Print !PlanID
.MoveNext
Next
End With
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top