Hello:

I am having a problem using Excel 97's VBA Interior object.

A little background on the app.

My Excel app has 5 worksheets, and in worksheet # 4 there is an ActiveX command
button that displays a User form. That user form has one button that queries
a database and fills columns 2 to 6 with data and paints the rows White or
Light green.

The problem is that sometimes the the module works perfectly, but more than
once the following error is displayed: "Run time error '1004': Unable to
set the Color property of the Interior Class".

The code is here:

Private Sub GetFinishedGoods()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fd As ADODB.Field
Dim strConnectionString As String
Dim intRow, intCol As Integer
Dim bolFirstRow As Boolean 'Flag: Selects what color will a specific
row be painted

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT DISTINCT ubcb010.tnmu019.pnpa FROM ubcb010.tnmu019 WHERE
ubcb010.tnmu019.pnpa Not Like 'E6%'"
cn.Open "DSN=bnd01pz0 F50;UID=odbc;PWD=odbc"
StatusBar.Panels(1).Text = "Status: Querying SIMAC"
rs.Open strSQL, cn, adOpenStatic, adLockPessimistic, adCmdText
intRow = 3
rs.MoveFirst
Set fd = rs.Fields(0)
bolFirstRow = True
ThisWorkbook.Worksheets(4).Activate 'Activates the target worksheet??
Do While Not rs.EOF
ThisWorkbook.Worksheets(4).Cells(intRow, 2).Value = Trim$(fd.Value)
If Not bolFirstRow Then
Range(Cells(intRow, 2), Cells(intRow, 6)).Interior.Color = 13564625
'----------->Light green color
Else
Range(Cells(intRow, 2), Cells(intRow, 6)).Interior.Color = RGB(255,
255, 255) '------->White
End If
For intCol = 3 To 5
ThisWorkbook.Worksheets(4).Cells(intRow, intCol).Value = 0
Next
ThisWorkbook.Worksheets(4).Cells(intRow, 6).HorizontalAlignment =
xlCenter
intRow = intRow + 1
StatusBar.Panels(1).Text = "Status: Printing " & Trim$(fd.Value)
bolFirstRow = Not bolFirstRow
rs.MoveNext
Loop
StatusBar.Panels(1).Text = "Status: Creating Borders" '---> For other
process
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub

Please help: