Is there a way to determine which rows of a subform have been selected?
If not i will have to introduce a check box to indicate which records have been selected.
Records selected in subform
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Records selected in subform
The SelTop property of a datasheet or continuous form is the record number (starting from 1) of the first selected record, and the SelHeight property is the number of selected records.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Records selected in subform
Thank you, where is that described in the documentation?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Records selected in subform
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Records selected in subform
How would you then reference these records in a continuous form. I have found something that will do it, however i am having trouble adressing the subform called deplist. The Set F code below results in a 13 Type Mismatch error:
I have overcome this by
Set F = Me.deplist.form
This is the code to address selected records in a subform, but the SelHeight returns a zero.
Can you help me?
Code: Select all
Dim F As Form
Set F = Me.deplist
Set F = Me.deplist.form
This is the code to address selected records in a subform, but the SelHeight returns a zero.
Code: Select all
Dim i As Long
Dim F As Form
Dim RSf As dao.Recordset
' Get the form and its recordset.
Set F = Me![deplist].Form
' Set F = Forms![Department Availability]!deplist.Form
Set RSf = F.RecordsetClone
' Move to the first record in the recordset.
RSf.MoveFirst
' Move to the first selected record.
RSf.Move F.SelTop - 1
' Enumerate the list of selected records presenting
' the CompanyName field in a message box.
For i = 1 To F.SelHeight
MsgBox RSf![DepartmentID] & " " & RSf!DefaultTech
RSf.MoveNext
Next i
RSf.close
Set RSf = Nothing
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Records selected in subform
I saw a google by Stephan Lebans describing it.
Introduce a couple of controls on the Main form, then in the Form_Click of the subform deplist I saved both the SelTop and SelHeight in the main controls of the main form.
Introduce a couple of controls on the Main form, then in the Form_Click of the subform deplist I saved both the SelTop and SelHeight in the main controls of the main form.