IU am trying to ste the forecolor of individual rows within a listbox, dependant upon the value of a variable attached to each row.
The following code works but applies the forecolor to the entire listbox - not just individual rows.
any clues????
Public Function funLstDeliverable()
'poulates total actual field
Dim conn As ADODB.Connection
Dim rsDeliverable As ADODB.Recordset
Dim strSQL As String
Dim strDeliverable
Dim intPhaseData As Integer
Dim lngEstimate As Long
Dim lngTotal As Long
Dim intCount As Integer
lstDeliverable.Enabled = True
strSQL = "SELECT DISTINCT [tblEstimates].[pkEstimateID], [tblPhase].[fldPhase], [tblDeliverables].[pkDeliverableID], [tblDeliverables].[fldDeliverable], [tblEstimates].[fldEstimate], [tblEstimates].[fldStart], [tblEstimates].[fldFinish], [tblEstimates].[fldLastActual], [tblEstimates].[fldTotalActual]"
strSQL = strSQL & " FROM tblPhase INNER JOIN (tblDeliverables INNER JOIN tblEstimates ON [tblDeliverables].[pkDeliverableID]=[tblEstimates].[fldDeliverablesID]) ON [tblPhase].[pkPhaseID]=[tblDeliverables].[fldPhaseID]"
strSQL = strSQL & " WHERE [tblPhase].[pkPhaseID]= " & lstPhase.ItemData(lstPhase.ListIndex) & " AND tblEstimates.fldProjectID=" & gProjID
'Set ADO connection
Set conn = CurrentProject.Connection
Set rsDeliverable = New ADODB.Recordset
'Open tables
rsDeliverable.Open strSQL, CurrentProject.Connection
intCount = 0
While Not rsDeliverable.EOF
lstDeliverable.RowSource = strSQL
lngEstimate = rsDeliverable("fldEstimate"
lngTotal = rsDeliverable("fldTotalActual"
'MsgBox "est = " & intEstimate & " Tot = " & intTotal
' If lngEstimate > lngTotal Then
' lstDeliverable.ForeColor = 8453888 'green
' ElseIf lngEstimate < lngTotal Then
' lstDeliverable.ForeColor = 255 'red
' End If
' intCount = intCount + 1
rsDeliverable.MoveNext
Wend
The following code works but applies the forecolor to the entire listbox - not just individual rows.
any clues????
Public Function funLstDeliverable()
'poulates total actual field
Dim conn As ADODB.Connection
Dim rsDeliverable As ADODB.Recordset
Dim strSQL As String
Dim strDeliverable
Dim intPhaseData As Integer
Dim lngEstimate As Long
Dim lngTotal As Long
Dim intCount As Integer
lstDeliverable.Enabled = True
strSQL = "SELECT DISTINCT [tblEstimates].[pkEstimateID], [tblPhase].[fldPhase], [tblDeliverables].[pkDeliverableID], [tblDeliverables].[fldDeliverable], [tblEstimates].[fldEstimate], [tblEstimates].[fldStart], [tblEstimates].[fldFinish], [tblEstimates].[fldLastActual], [tblEstimates].[fldTotalActual]"
strSQL = strSQL & " FROM tblPhase INNER JOIN (tblDeliverables INNER JOIN tblEstimates ON [tblDeliverables].[pkDeliverableID]=[tblEstimates].[fldDeliverablesID]) ON [tblPhase].[pkPhaseID]=[tblDeliverables].[fldPhaseID]"
strSQL = strSQL & " WHERE [tblPhase].[pkPhaseID]= " & lstPhase.ItemData(lstPhase.ListIndex) & " AND tblEstimates.fldProjectID=" & gProjID
'Set ADO connection
Set conn = CurrentProject.Connection
Set rsDeliverable = New ADODB.Recordset
'Open tables
rsDeliverable.Open strSQL, CurrentProject.Connection
intCount = 0
While Not rsDeliverable.EOF
lstDeliverable.RowSource = strSQL
lngEstimate = rsDeliverable("fldEstimate"
lngTotal = rsDeliverable("fldTotalActual"
'MsgBox "est = " & intEstimate & " Tot = " & intTotal
' If lngEstimate > lngTotal Then
' lstDeliverable.ForeColor = 8453888 'green
' ElseIf lngEstimate < lngTotal Then
' lstDeliverable.ForeColor = 255 'red
' End If
' intCount = intCount + 1
rsDeliverable.MoveNext
Wend