0

I want to make a database query to retrieve the date of holidays and compare with the days in columns of the msflexgrid. If there's a match I want to mark it in red.

Private Sub Text1_LostFocus(Index As Integer)
Select Case Index
    Case 1
        Grid.Clear
        fechainicial = "01/" & Text1(1) & "/" & Text1(0)
        numdias = DaysInMonth(fechainicial)
        Grid.Cols = numdias + 2
        For i = 0 To numdias
                With Grid
                    .Redraw = False
                    .Rows = 4
                    .FixedRows = 2
                    For ii = 0 To .Rows - 1
                        .RowHeight(ii) = 300
                    Next
                    .RowHeight(2) = 0
                    .ColWidth(0) = 300
                    .ColWidth(i + 1) = 450
                    If i <= .Cols - 3 Then
                        .TextMatrix(0, i + 1) = Format(CStr(FormatDateTime(fechainicial + i, vbShortDate)), "d")
                        .TextMatrix(1, i + 1) = UCase(Format(i + 1 & "/" & Text1(1) & "/" & Text1(0), "ddd"))
                    End If
                    If Weekday(fechainicial + i, vbMonday) = 7 Then
                        numc = i + 1
                        fila = 1
                        .Col = numc
                        .Row = fila
                        .CellForeColor = vbRed
                        .TextMatrix(2, i + 1) = "D"
                    End If

                    .ColWidth(.Cols - 1) = 900
                    .TextMatrix(0, .Cols - 1) = "HORAS"
                    .Col = 1
                    .Row = 3
                    .Redraw = True
                End With
            Next i
        'End If
End Select
End Sub

table of database: FESTIVOS, fields: id,fecha,descripcion

Rich
  • 6,470
  • 15
  • 32
  • 53
  • Welcome to stackoverflow. Consider reading this article on [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and this one on how to create a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve). – jtate Mar 19 '19 at 20:55
  • Also, dont forget to state your actual question/where you are stuck. – mattias Mar 19 '19 at 21:08

0 Answers0