Private Sub Command1_Click()
Dim sRow As Byte, i As Byte
Dim rs As New ADODB.Recordset
Dim Sql As String
Sql = " select * from IT_CPAR where CAR_SDATE between '" & Format(DTPicker1.Value, "dd-MMM-yy") & "' and '" & Format(DTPicker2.Value, "dd-MMM-yy") & "' and CAR_TYPE like '%" & Trim(Combo1.Text) & "' order by CAR_ID "
MsgBox Sql
If rs.State = adStateOpen Then rs.Close
rs.Open Sql, Conn, adOpenForwardOnly, adLockReadOnly, 1
Set FlexGrid1.DataSource = rs
Call SetupGrid 'สั่งตั้งค่า Flexgrid
With FlexGrid1
For i = 1 To .Rows - 1
If .TextMatrix(i, 6) = "ปิด" Then
.Row = i
For n = 1 To .Cols - 1
.Col = n
.CellBackColor = vbRed
Next n
End If
Next i
End With
End Sub