views:

61

answers:

2

In a continuous subform, I display records based on a DISTINCT query. Because it's distinct, each row does not include a record ID.

Does anyone know of a way to add a checkbox (or similar), so that a user can select any of the records, which will then be used to create new records via code?

I prefer to use a subform to a list, as it features lots of column sorting and filtering functions.

MTIA

+1  A: 

Depending on what you need to create the records, something like this sample may suit:

Function DisplaySelectedCompanyNames()
   Dim i As Long
   Dim F As Form
   Dim RS As Recordset

   '' Get the form and its recordset.
   Set F = Forms![Customers1]
   Set RS = F.RecordsetClone

   '' Move to the first record in the recordset.
   RS.MoveFirst

   '' Move to the first selected record.
   RS.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 RS![CompanyName]
     RS.MoveNext
   Next i

End Function

Further information: http://support.microsoft.com/kb/208502

Remou
Unfortunately, that won't help, as users are then limited to contiguous records. Also, its not particularly intuitive. I'm trying everything I can to somehow 'flag' a hidden field - the 'checkbox' can then just be a textbox displaying the Wingding relevant checkbox characters.I've been trying to use the 'row highlighting' method, where an unbound field set to its row number. This is a case where each unbound field, in each row, has a different value (ie, its row num).Just can't seem to quite get there.
maxhugen
I am fairly sure you cannot get anywhere with unbound controls and continuous forms. I guess you could copy the relevant record to, say, a listbox on the main form as a value when a record is selected.
Remou
A: 

FYI, I decided to use the Windows ListView OCX control, as it offers the ability to add a checkbox for each row.

maxhugen