A.D.TEJPAL
adtp at hotmail.com
Fri May 12 13:39:27 CDT 2006
Mark, On a continuous form, so long as record selectors are available, you can pick up the selection via form's click event and then apply dynamic conditional formatting so as to highlight only the records covered by current selection. Form's SelTop & SelHeight properties are handy in this context. Sample code as given below, will ensure that all records currently selected by the user get distinctly highlighted across the full row. Note - The performance of conditional formatting in Access 2003 is found to be better than that in Access 2000 (Access 2000 file format in both cases). Best wishes, A.D.Tejpal --------------- Code in module of continuous form (ID is the name of primary key field) ========================================= Private Sub Form_Click() P_SetFormat_A End Sub ---------------------------------------------------------------------------- Private Sub Form_Current() P_SetFormat_A End Sub ---------------------------------------------------------------------------- Private Function Fn_SelectedBlock(ByVal PkNumber _ As Long) As Long ' Returns 1 if the record with this PkNumber ' falls in selected block, otherwise 0 Dim rst As DAO.Recordset Dim RecNum As Long, InSelection As Long InSelection = 0 ' Default Set rst = Me.RecordsetClone rst.FindFirst "ID = " & PkNumber If Not rst.NoMatch Then RecNum = rst.AbsolutePosition + 1 If RecNum >= Me.SelTop And _ RecNum <= Me.SelTop + _ (Me.SelHeight - 1) Then InSelection = 1 End If End If Fn_SelectedBlock = InSelection rst.Close Set rst = Nothing End Function ---------------------------------------------------------------------------- Public Sub P_SetFormat_A() ' Sets fresh Conditional Formatting in Detail section Dim ct As Control For Each ct In Me.Detail.Controls P_SetFormat_B ct.Name Next Me.Repaint End Sub ---------------------------------------------------------------------------- Private Sub P_SetFormat_B(ByVal ControlName As String) ' Sets fresh Conditional Formatting ' (in text box named ControlName) Dim Cdn As String On Error Resume Next ' For controls not suited to ' conditional formatting With Me(ControlName).FormatConditions .Delete Cdn = "Fn_SelectedBlock(ID) <> 0" With .Add(acExpression, , Cdn) .BackColor = 16777164 .FontBold = True End With End With On Error GoTo 0 End Sub ========================================= ----- Original Message ----- From: Mark A Matte To: accessd at databaseadvisors.com Sent: Friday, May 12, 2006 21:41 Subject: [AccessD] Select Multiple records on form Hello All, I'm probably missing something simple here...but...I have a continuous form in A2K using a NON-updateable recordset. I would like the user to be able to select multiple records...and then click a button to do some other stuff. My issue is how to select multiple records on this form...I'm thinking some sort of conditional formatting...but not sure. Any ideas/suggestions/direction? Thanks, Mark A. Matte