Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needhelp with styling list box

Status
Not open for further replies.

joester

Technical User
Aug 18, 2002
2
AU
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top