开发者

Tagging Records in a Continuous Form

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 use开发者_开发百科r 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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜