ALTERAR A COR DAS LINHAS CONFORME O CRITERIOS

USUARIO.EXCLUIDOS 07/09/2007 23:20:32
#234700
tenho uma grade (msflexgrid) em uma coluna tem a data de vencimento de processo gostaria que quando faltasse um dia para vencer o processo a linha no msflexgrid mudasse de cor. Gostaria de auxilio.

Estou utilizando a codificação abaixo para preencher a grade.

Private Sub Processo()


msfgrade.Cols = 5 'define as colunas
msfgrade.Rows = 2 'define as linhas
msfgrade.FixedRows = 1 'uma linha de titulo
msfgrade.FixedCols = 0 'nenhuma coluna de titulo
msfgrade.TextMatrix(0, 0) = "Sinistro" 'linha e coluna
msfgrade.TextMatrix(0, 1) = "Sindicante"
msfgrade.TextMatrix(0, 2) = "Segurado"
msfgrade.TextMatrix(0, 3) = "Recebimento"
msfgrade.TextMatrix(0, 4) = "Entrega"
msfgrade.ColWidth(0) = 900 'largura da coluna 0
msfgrade.ColWidth(1) = 2450
msfgrade.ColWidth(2) = 2450
msfgrade.ColWidth(3) = 1200
msfgrade.ColWidth(4) = 1200
Lin = 0
CONSULTASQL = "SELECT * " & _
"FROM Tabprocessos "
Set TBSQL = CON.Execute(CONSULTASQL)
Do Until TBSQL.EOF
Lin = Lin + 1
msfgrade.Rows = Lin + 1
msfgrade.TextMatrix(Lin, 0) = TBSQL("Processo")
msfgrade.TextMatrix(Lin, 1) = TBSQL("prestador")
msfgrade.TextMatrix(Lin, 2) = TBSQL("Proprietario")
msfgrade.TextMatrix(Lin, 3) = TBSQL("recebimento_data")
msfgrade.TextMatrix(Lin, 4) = TBSQL("data_entrega")
TBSQL.MoveNext
Loop

End Sub

USUARIO.EXCLUIDOS 07/09/2007 23:55:40
#234702
Resposta escolhida
Estou supondo que a data de vencimento seja data_entrega.

ficaria assim:
Dim DataCompara As Date
DataCompara = Format(TBSQL("data_entrega"), "dd/mm/yyyy")
if DataCompara-1=Format(Now, "dd/mm/yyyy") then
msfgrade.row=Lin
msfgrade.col=4
msfgrade.CellBackColor=vbRed
end if
msfgrade.TextMatrix(Lin, 4) = TBSQL("data_entrega")
USUARIO.EXCLUIDOS 08/09/2007 00:04:42
#234703
Em qual parte do programa posso inserir a codificação acima, tentei dentro do laço de repetição, porém ocorreu erro "13 Type Mismatch"


USUARIO.EXCLUIDOS 08/09/2007 00:07:56
#234704
Do Until TBSQL.EOF
Lin = Lin + 1
msfgrade.Rows = Lin + 1
msfgrade.TextMatrix(Lin, 0) = TBSQL("Processo")
msfgrade.TextMatrix(Lin, 1) = TBSQL("prestador")
msfgrade.TextMatrix(Lin, 2) = TBSQL("Proprietario")
msfgrade.TextMatrix(Lin, 3) = TBSQL("recebimento_data")
Dim DataCompara As Date
DataCompara = Format(TBSQL("data_entrega"), "dd/mm/yyyy")
if DataCompara-1=Format(Now, "dd/mm/yyyy") then
msfgrade.row=Lin
msfgrade.col=4
msfgrade.CellBackColor=vbRed
end if
msfgrade.TextMatrix(Lin, 4) = TBSQL("data_entrega")
TBSQL.MoveNext
Loop

USUARIO.EXCLUIDOS 08/09/2007 00:32:49
#234705
marivilha funcionou. Existe a possibilidade de o vermelho selecionar toda linha, não somente a celular em si??
MARCELOKROL 08/09/2007 09:23:20
#234714
é so mudar a coluna assim
(...)
msfgrade.col=1
msfgrade.CellBackColor=vbRed
msfgrade.col=2
msfgrade.CellBackColor=vbRed
msfgrade.col=3
msfgrade.CellBackColor=vbRed
msfgrade.col=4
msfgrade.CellBackColor=vbRed
...
msfgrade.col=99999 (exagerei)
msfgrade.CellBackColor=vbRed
USUARIO.EXCLUIDOS 08/09/2007 10:25:37
#234718
Tem que ser dentro de um loop, pois infelizmente se vc não mensionar a linha a cada vez que menciona a coluna não funciona.

if DataCompara-1=Format(Now, "dd/mm/yyyy") then
for i= 0 to 4
msfgrade.row=Lin
msfgrade.col=i
msfgrade.CellBackColor=vbRed
next
end if


Tópico encerrado , respostas não são mais permitidas