VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form_EstadUTP 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Unidad Técnico Pedagógica"
   ClientHeight    =   7470
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11085
   Icon            =   "Form_EstadUTP.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7470
   ScaleWidth      =   11085
   Begin VB.Frame Frame_Rendimientoprofes 
      Height          =   7215
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   10815
      Begin VB.Frame Frame4 
         Caption         =   "Año de búsqueda"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   120
         TabIndex        =   45
         Top             =   1200
         Width           =   2655
         Begin VB.ComboBox cb_agno 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   46
            Text            =   "Combo1"
            Top             =   240
            Width           =   2415
         End
      End
      Begin VB.OptionButton Opt_destino 
         Caption         =   "Pantalla"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   6120
         TabIndex        =   25
         Top             =   1800
         Width           =   1095
      End
      Begin VB.OptionButton Opt_destino 
         Caption         =   "Impresora"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   4440
         TabIndex        =   24
         Top             =   1800
         Width           =   1095
      End
      Begin VB.CommandButton Btn_limpiar 
         Caption         =   "Limpiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   23
         Top             =   360
         Width           =   1575
      End
      Begin VB.CommandButton btn_gen_reporte 
         Caption         =   "Generar Informe"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   22
         Top             =   840
         Width           =   1575
      End
      Begin VB.CommandButton btn_can_EstadUtp 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   21
         Top             =   1320
         Width           =   1575
      End
      Begin VB.Frame Frame_tipo_busqueda 
         Caption         =   "Tipo de búsqueda"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   975
         Left            =   120
         TabIndex        =   14
         Top             =   120
         Width           =   2655
         Begin VB.OptionButton Opt_profeasig 
            Caption         =   "Busqueda por Profesor"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   16
            Top             =   600
            Width           =   2055
         End
         Begin VB.OptionButton Opt_profeasig 
            Caption         =   "Busqueda por Subsector"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   15
            Top             =   360
            Width           =   2175
         End
      End
      Begin VB.Frame Frame5 
         Caption         =   "Rendimiento del profesor"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   4815
         Left            =   120
         TabIndex        =   1
         Top             =   2160
         Width           =   10575
         Begin VB.CommandButton Btn_Carga_grilla_oculta 
            Caption         =   "Carga oculta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3120
            TabIndex        =   44
            Top             =   600
            Visible         =   0   'False
            Width           =   1215
         End
         Begin MSFlexGridLib.MSFlexGrid Grd_rendimiento 
            Height          =   4455
            Left            =   120
            TabIndex        =   2
            Top             =   240
            Width           =   10335
            _ExtentX        =   18230
            _ExtentY        =   7858
            _Version        =   393216
            Rows            =   15
            FixedRows       =   2
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
         End
      End
      Begin VB.Frame Frame_profeasig 
         Height          =   1575
         Index           =   0
         Left            =   2880
         TabIndex        =   8
         Top             =   120
         Width           =   5895
         Begin VB.ListBox lst_nom_asi_prof 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   900
            Left            =   1440
            TabIndex        =   11
            Top             =   480
            Visible         =   0   'False
            Width           =   3735
         End
         Begin VB.TextBox txt_nom_asi_prof 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   1920
            MaxLength       =   30
            TabIndex        =   9
            Top             =   240
            Width           =   3735
         End
         Begin VB.ComboBox cmb_asig_impart 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1920
            TabIndex        =   10
            Text            =   "cmb_asig_impart"
            Top             =   600
            Width           =   3735
         End
         Begin VB.ComboBox cmb_Periodo_Prof 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1920
            TabIndex        =   17
            Top             =   960
            Width           =   3735
         End
         Begin VB.Label Label1 
            Caption         =   "Período"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   18
            Top             =   960
            Width           =   855
         End
         Begin VB.Label Label18 
            Caption         =   "Asignaturas impartidas"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   13
            Top             =   600
            Width           =   1935
         End
         Begin VB.Label lbl_nom_PRO 
            Caption         =   "Nombre del profesor"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   12
            Top             =   240
            Width           =   1575
         End
      End
      Begin VB.Frame Frame_profeasig 
         Height          =   1575
         Index           =   1
         Left            =   2880
         TabIndex        =   3
         Top             =   120
         Width           =   5895
         Begin VB.ComboBox cmb_Periodo_subsec 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1920
            TabIndex        =   19
            Top             =   960
            Width           =   3735
         End
         Begin VB.ComboBox cmb_asig_exist 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1920
            TabIndex        =   5
            Top             =   240
            Width           =   3735
         End
         Begin VB.ComboBox cmb_profes_asig 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   1920
            TabIndex        =   4
            Top             =   600
            Width           =   3735
         End
         Begin VB.Label Label2 
            Caption         =   "Período"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   20
            Top             =   960
            Width           =   855
         End
         Begin VB.Label Label19 
            Caption         =   "Impartida por el profesor"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   7
            Top             =   600
            Width           =   1695
         End
         Begin VB.Label Label20 
            Caption         =   "Subsectores"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   6
            Top             =   240
            Width           =   1095
         End
      End
   End
   Begin VB.Frame Frame_Rendcurso 
      ForeColor       =   &H00FF0000&
      Height          =   7215
      Left            =   120
      TabIndex        =   26
      Top             =   120
      Width           =   10815
      Begin VB.CommandButton Btn_limpiar_Rendcurso 
         Caption         =   "Limpiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   39
         Top             =   1080
         Width           =   1575
      End
      Begin VB.CommandButton Btn_gen_Rep_Rendcurso 
         Caption         =   "Generar Informe"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   38
         Top             =   600
         Width           =   1575
      End
      Begin VB.CommandButton Btn_can_Rep_Rendcurso 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9000
         TabIndex        =   37
         Top             =   1560
         Width           =   1575
      End
      Begin VB.Frame Frame2 
         Caption         =   "Parámetros de Búsqueda"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   1935
         Left            =   120
         TabIndex        =   27
         Top             =   240
         Width           =   8655
         Begin VB.ComboBox Combo1 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            Style           =   2  'Dropdown List
            TabIndex        =   47
            Top             =   1320
            Width           =   1215
         End
         Begin VB.Frame Frame1 
            Caption         =   "Destino"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   735
            Left            =   4920
            TabIndex        =   41
            Top             =   960
            Width           =   3495
            Begin VB.OptionButton Opt_destino_rendcurso 
               Caption         =   "Impresora"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Index           =   1
               Left            =   2040
               TabIndex        =   43
               Top             =   360
               Width           =   1335
            End
            Begin VB.OptionButton Opt_destino_rendcurso 
               Caption         =   "Pantalla"
               BeginProperty Font 
                  Name            =   "Arial"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Index           =   0
               Left            =   240
               TabIndex        =   42
               Top             =   360
               Width           =   1335
            End
         End
         Begin VB.CommandButton btn_carga_grilla_oculta_rendcurso 
            Caption         =   "Carga oculta"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   2040
            TabIndex        =   40
            Top             =   960
            Visible         =   0   'False
            Width           =   1215
         End
         Begin VB.ComboBox cmb_per_rendcurso 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   4920
            TabIndex        =   35
            Top             =   480
            Width           =   3495
         End
         Begin VB.CheckBox chk_todos_niveles_rendcurso 
            Caption         =   "Todos los niveles"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   1680
            TabIndex        =   34
            Top             =   1440
            Width           =   1575
         End
         Begin VB.ListBox lst_niveles_rendcurso 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1020
            Left            =   3360
            Style           =   1  'Checkbox
            TabIndex        =   33
            Top             =   600
            Width           =   1095
         End
         Begin VB.ComboBox cmb_mod_rendcurso 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   330
            Left            =   120
            TabIndex        =   28
            Top             =   600
            Width           =   3135
         End
         Begin VB.Label Label6 
            Caption         =   "Año"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   48
            Top             =   1080
            Width           =   1215
         End
         Begin VB.Line Line2 
            BorderColor     =   &H8000000C&
            X1              =   4680
            X2              =   4680
            Y1              =   120
            Y2              =   1935
         End
         Begin VB.Line Line3 
            BorderColor     =   &H80000005&
            X1              =   4680
            X2              =   4680
            Y1              =   120
            Y2              =   1935
         End
         Begin VB.Label Label5 
            Caption         =   "Período"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   4920
            TabIndex        =   36
            Top             =   240
            Width           =   855
         End
         Begin VB.Label Label4 
            Caption         =   "Niveles"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3360
            TabIndex        =   30
            Top             =   360
            Width           =   855
         End
         Begin VB.Label Label3 
            Caption         =   "Tipo de Enseñanza"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   120
            TabIndex        =   29
            Top             =   360
            Width           =   1575
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Rendimiento de los cursos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   4815
         Left            =   120
         TabIndex        =   31
         Top             =   2280
         Width           =   10575
         Begin MSFlexGridLib.MSFlexGrid grd_rendcurso 
            Height          =   4455
            Left            =   120
            TabIndex        =   32
            Top             =   240
            Width           =   10335
            _ExtentX        =   18230
            _ExtentY        =   7858
            _Version        =   393216
            Rows            =   1
            Cols            =   1
            FixedRows       =   0
            FixedCols       =   0
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
         End
      End
   End
End
Attribute VB_Name = "Form_EstadUTP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Subsectoresi() As String, Codsec As String, Codasi As String, Subsector As String
Dim Cursosimpartidos() As String, Totalcursos As Integer
Dim RutProfe As String, Busqueda As String, Profesor As String
Dim Codperiodo As String, IndicePeriodo As String, periodo As String
Dim Subsectorescurso() As String ' Rendimientos de curso
Dim Nsubsectores As Integer
Dim Cursosrend() As String
Sub Grillainicial2()
Me.grd_rendcurso.Clear
Me.grd_rendcurso.Rows = 2
Me.grd_rendcurso.Cols = 10
Me.grd_rendcurso.FixedCols = 2
Me.grd_rendcurso.FixedRows = 1
Me.grd_rendcurso.MergeCells = 2
Me.grd_rendcurso.MergeCol(0) = True
Me.grd_rendcurso.FormatString = "                      |^  Cursos  |^ Matrícula|^ General|^ Más alto|^ Más bajo|^ 6,0 y 7,0|^ 5,0 y 5,9|^ 4,0 y 4,9|^ 3,0 y 3,9|^ 2,0 y 2,9|^ 1,0 y 1,9|^ Sin promedio|^ Deficientes"
End Sub

Sub Grillainicial()
Me.Grd_rendimiento.Clear
Me.Grd_rendimiento.Rows = 15
Me.Grd_rendimiento.Cols = 4
Me.Grd_rendimiento.MergeCells = flexMergeNever
Me.Grd_rendimiento.FormatString = "               ;|Cursos que atiende|Matrícula|Promedio del Curso|Promedio más alto|Promedio más bajo|Distribución alumnos por rango|Entre 6,0 y 7,0|Entre 5,0 y 5,9|Entre 4,0 y 4,9|Entre 3,0 y 3,9|Entre 2,0 y 2,9|Entre 1,0 y 1,9|Total alumnos evaluados|Alumnos sin promedio|Total alumnos nota deficiente"
'Me.Grd_rendimiento.MergeRow(0) = True
'For t = 1 To 14
'    If t = 6 Then
'        Me.Grd_rendimiento.MergeRow(t) = True
'    Else
'        Me.Grd_rendimiento.MergeRow(t) = False
'    End If
'Next t
'Me.Grd_rendimiento.ColWidth(colpromedio) = 1000
Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = 2: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = 2: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.TextMatrix(0, 1) = "Detalles "
Me.Grd_rendimiento.TextMatrix(1, 1) = ""
Me.Grd_rendimiento.ColWidth(2) = 1500
Me.Grd_rendimiento.ColWidth(3) = 1500
' Tabla Comparativa Promedios
Me.Grd_rendimiento.TextMatrix(0, 2) = "Periodo"
Me.Grd_rendimiento.TextMatrix(0, 3) = "Año"
Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = 1: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.TextMatrix(1, 2) = "Anterior"
Me.Grd_rendimiento.TextMatrix(1, 3) = "Anterior"
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = 1: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = 2: Me.Grd_rendimiento.CellAlignment = 4
'Me.Grd_rendimiento.Col = 1: Me.Grd_rendimiento.Row = 6: Me.Grd_rendimiento.CellBackColor = &HFF&
'Me.Grd_rendimiento.MergeCol(colpromedio) = True
'Me.Grd_rendimiento.MergeCol(colpromedio + 1) = False
'Me.Grd_rendimiento.MergeCol(colpromedio + 2) = False

End Sub
Private Sub btn_can_EstadUtp_Click()
Unload Me
End Sub

Private Sub Btn_can_Rep_Rendcurso_Click()
Unload Me
End Sub

Private Sub Btn_Carga_grilla_oculta_Click()
Dim NumGra As String, letra As String, Codens As String, Cadenacurso As String
Dim FechaFinPer As Date, Finperiodo As Date
Call Grillainicial
Me.Grd_rendimiento.Cols = 1 + Totalcursos + 3
colpromedio = Totalcursos + 1
Form_Progress.Label1.Caption = "Cargando ..."
Form_Progress.Show
Abarra = (Totalcursos * 13) + Totalcursos + 1
Form_Progress.ProgBar1.MaxValue = Abarra
Abarra = 0
For t = 1 To Totalcursos
    Me.Grd_rendimiento.ColWidth(t) = 1000
    Me.Grd_rendimiento.TextMatrix(0, t) = t
    'If Cursosimpartidos(t - 1, 1) = "110" Then modalidad = " Eb"
    If Cursosimpartidos(t - 1, 1) = "310" Then modalidad = " em"
    Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.CellAlignment = 4
    Me.Grd_rendimiento.TextMatrix(1, t) = Cursosimpartidos(t - 1, 2) & "º" & Cursosimpartidos(t - 1, 3) & modalidad
    Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.CellAlignment = 4
    Abarra = Abarra + 1
    Form_Progress.ProgBar1.ShowProgress Abarra
    Form_Progress.SetFocus
    DoEvents
Next t
For t = 1 To Me.Grd_rendimiento.Cols - 1
    Me.Grd_rendimiento.Row = 6: Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.CellBackColor = &H8000000F
    Me.Grd_rendimiento.TextMatrix(6, t) = " "
Next t

Me.Grd_rendimiento.ColWidth(colpromedio) = 1000
Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = colpromedio: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = colpromedio: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.TextMatrix(0, colpromedio) = "Detalles "
Me.Grd_rendimiento.TextMatrix(1, colpromedio) = "Totales"
Me.Grd_rendimiento.ColWidth(colpromedio + 1) = 1000
Me.Grd_rendimiento.ColWidth(colpromedio + 2) = 1000
Me.Grd_rendimiento.TextMatrix(0, colpromedio + 1) = "Periodo"
Me.Grd_rendimiento.TextMatrix(0, colpromedio + 2) = "Año"
Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = colpromedio + 1: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.Row = 0: Me.Grd_rendimiento.Col = colpromedio + 2: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.TextMatrix(1, colpromedio + 1) = "Anterior"
Me.Grd_rendimiento.TextMatrix(1, colpromedio + 2) = "Anterior"
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = colpromedio + 1: Me.Grd_rendimiento.CellAlignment = 4
Me.Grd_rendimiento.Row = 1: Me.Grd_rendimiento.Col = colpromedio + 2: Me.Grd_rendimiento.CellAlignment = 4
Abarra = Abarra + 1
    Finperiodo = DevuelveCampo("periodos", "", "fec_ter_per", "fec_ter_per <> '' order by fec_ter_per desc", conn)
    'Finperiodo = "30-11-" & Anno ' Parametrizar esta fecha
    If IndicePeriodo = -1 Then
        campo = "PG"
        FechaFinPer = Finperiodo
    Else
        FechaFinPer = DevuelveCampo("periodos", "", "fec_ter_per", "num_per= '" & IndicePeriodo & "'", conn)
        If FechaFinPer >= Finperiodo Then
            FechaFinPer = Finperiodo
        End If
        If IndicePeriodo = 0 Then
           campo = "P1"
        ElseIf IndicePeriodo = 1 Then
            campo = "P2"
        ElseIf IndicePeriodo = 2 Then
            campo = "P3"
        End If
    End If

For t = 1 To Totalcursos
    Codens = Cursosimpartidos(t - 1, 1)
    NumGra = Cursosimpartidos(t - 1, 2)
    letra = Cursosimpartidos(t - 1, 3)
    'MAtricula = CuentaReg("alu_x_cur", "cod_ens = '" & Codens & "' and num_gra = '" & Numgra & "' and let_cur ='" & Letra & "' and ucase(activo_alu)='SI'")
    rs.CursorLocation = adUseClient: rs.Open "select count(a.ci_alu) from alu_x_cur a, matriculas m where a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and m.fec_mat=a.fec_mat and a.cod_ens ='" & Codens & "' and a.num_gra = '" & NumGra & "' and a.let_cur ='" & letra & "' and ucase(a.activo_alu)='SI' and a.fec_cam='1111-11-11' and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and agno = " & cb_agno.Text & " and a.agno = m.anno_mat", conn: matricula = rs(0): rs.Close
    
    'select count(a.ci_alu) from alu_x_cur a, matriculas m where a.ci_alu=m.ci_alu and a.cod_ens = '110' and a.num_gra = '3' and a.let_cur ='G' and  a.fec_cam='1111-11-11'  and m.fec_mat <= '30-11-2003'  and ucase(a.activo_alu)='SI'
    Me.Grd_rendimiento.TextMatrix(2, t) = matricula: Abarra = Abarra + 1
    
    
    'a = "select count(p.P2) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and   p.cod_ens = '" & CodEns & "' and p.num_gra = '" & numgra & "' and p.letra_curso ='" & Letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 1.0 ' and p.P1 <=1.9"
    
    rs.CursorLocation = adUseClient: rs.Open "select avg(" & campo & ") from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and   p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 1.0 and a.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Promediocurso = rs(0): rs.Close
    If IsNull(Promediocurso) Then
        Promediocurso = "-"
    Else
        Promediocurso = IIf(Len(CStr(Promediocurso)) = 1, Format(Promediocurso, ".0"), Mid(CStr(Promediocurso), 1, 3))
        Colorcel = IIf(Promediocurso < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 3: Me.Grd_rendimiento.CellForeColor = Colorcel
    End If
    Me.Grd_rendimiento.TextMatrix(3, t) = Promediocurso: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select max(" & campo & ") from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and   p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 1.0 and a.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: maximo = rs(0): rs.Close
    If IsNull(maximo) Then
        maximo = "-"
    Else
        maximo = IIf(Len(CStr(maximo)) = 1, Format(maximo, ".0"), Mid(CStr(maximo), 1, 3))
        Colorcel = IIf(maximo < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 4: Me.Grd_rendimiento.CellForeColor = Colorcel
    End If
    Me.Grd_rendimiento.TextMatrix(4, t) = maximo: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select min(" & campo & ") from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and   p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 1.0 and a.agno = " & cb_agno.Text & " and p.agno = m.anno_mat and a.agno = p.agno", conn: minimo = rs(0): rs.Close
    If IsNull(minimo) Then
        minimo = "-"
    Else
        minimo = IIf(Len(CStr(minimo)) = 1, Format(minimo, ".0"), Mid(CStr(minimo), 1, 3))
        Colorcel = IIf(minimo < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
    End If
    Me.Grd_rendimiento.TextMatrix(5, t) = minimo: Abarra = Abarra + 1
    
    'For h = 1 To Me.Grd_rendimiento.Cols - 1
    '    Me.Grd_rendimiento.Row = 6: Me.Grd_rendimiento.Col = h
    '    Me.Grd_rendimiento.CellBackColor = &H808080
    'Next h
    Abarra = Abarra + 1
    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 6.0 and p." & campo & " <= 7.0 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango1 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(7, t) = Rango1: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 5.0 and p." & campo & " <= 5.9 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango2 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(8, t) = Rango2: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 4.0 and p." & campo & " <= 4.9 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango3 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(9, t) = Rango3: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 3.0 and p." & campo & " <= 3.9 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango4 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(10, t) = Rango4: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 2.0 and p." & campo & " <= 2.9 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango5 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(11, t) = Rango5: Abarra = Abarra + 1

    rs.CursorLocation = adUseClient: rs.Open "select count(distinct p.ci_alu) from promedios p, alu_x_cur a, matriculas m where p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & Codens & "' and p.num_gra = '" & NumGra & "' and p.letra_curso ='" & letra & "' and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and p." & campo & " >= 1.0 and p." & campo & " <= 1.9 and p.agno = " & cb_agno.Text & " and p.agno = a.agno and p.agno = m.anno_mat", conn: Rango6 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(12, t) = Rango6: Abarra = Abarra + 1
    
    Me.Grd_rendimiento.TextMatrix(13, t) = (CInt(Me.Grd_rendimiento.TextMatrix(7, t)) + CInt(Me.Grd_rendimiento.TextMatrix(8, t)) + CInt(Me.Grd_rendimiento.TextMatrix(9, t)) + CInt(Me.Grd_rendimiento.TextMatrix(10, t)) + CInt(Me.Grd_rendimiento.TextMatrix(11, t)) + CInt(Me.Grd_rendimiento.TextMatrix(12, t)))
    
    Me.Grd_rendimiento.TextMatrix(14, t) = CInt(Me.Grd_rendimiento.TextMatrix(2, t)) - (CInt(Me.Grd_rendimiento.TextMatrix(7, t)) + CInt(Me.Grd_rendimiento.TextMatrix(8, t)) + CInt(Me.Grd_rendimiento.TextMatrix(9, t)) + CInt(Me.Grd_rendimiento.TextMatrix(10, t)) + CInt(Me.Grd_rendimiento.TextMatrix(11, t)) + CInt(Me.Grd_rendimiento.TextMatrix(12, t)))
    Abarra = Abarra + 1
    
    Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 15: Me.Grd_rendimiento.CellForeColor = &HFF&
    Me.Grd_rendimiento.TextMatrix(15, t) = CInt(Me.Grd_rendimiento.TextMatrix(10, t)) + CInt(Me.Grd_rendimiento.TextMatrix(11, t)) + CInt(Me.Grd_rendimiento.TextMatrix(12, t))
    Abarra = Abarra + 1
        
    'Cadenacurso = Cadenacurso & " (cod_ens = '" & Cursosimpartidos(t - 1, 1) & "' and num_gra = '" & Cursosimpartidos(t - 1, 2) & "' and letra_curso ='" & Cursosimpartidos(t - 1, 3) & "') or "
        
    Form_Progress.ProgBar1.ShowProgress Abarra
    Form_Progress.SetFocus
    DoEvents

Next t
Divpromgral = 0: Divprommax = 0: Divprommin = 0
Sumapromgral = 0: Sumaprommax = 0: Sumaprommin = 0
For t = 1 To Totalcursos
    Sumamat = Sumamat + val(Me.Grd_rendimiento.TextMatrix(2, t))
    If Me.Grd_rendimiento.TextMatrix(3, t) <> "-" Then
        Divpromgral = Divpromgral + 1
        Sumapromgral = Sumapromgral + CDec(Me.Grd_rendimiento.TextMatrix(3, t))
    End If
    If Me.Grd_rendimiento.TextMatrix(4, t) <> "-" Then
        Divprommax = Divprommax + 1
        Sumaprommax = Sumaprommax + CDec(Me.Grd_rendimiento.TextMatrix(4, t))
    End If
    If Me.Grd_rendimiento.TextMatrix(5, t) <> "-" Then
        Divprommin = Divprommin + 1
        Sumaprommin = Sumaprommin + CDec(Me.Grd_rendimiento.TextMatrix(5, t))
    End If
    Suma6070 = Suma6070 + val(Me.Grd_rendimiento.TextMatrix(7, t))
    Suma5059 = Suma5059 + val(Me.Grd_rendimiento.TextMatrix(8, t))
    Suma4049 = Suma4049 + val(Me.Grd_rendimiento.TextMatrix(9, t))
    Suma3039 = Suma3039 + val(Me.Grd_rendimiento.TextMatrix(10, t))
    Suma2029 = Suma2029 + val(Me.Grd_rendimiento.TextMatrix(11, t))
    Suma1019 = Suma1019 + val(Me.Grd_rendimiento.TextMatrix(12, t))
    Sumaconprom = Sumaconprom + val(Me.Grd_rendimiento.TextMatrix(13, t))
    Sumasinprom = Sumasinprom + val(Me.Grd_rendimiento.TextMatrix(14, t))
    Sumadefic = Sumadefic + val(Me.Grd_rendimiento.TextMatrix(15, t))

Next t
' Corrección de desbordamiento
Me.Grd_rendimiento.TextMatrix(2, t) = Sumamat
If Sumapromgral > 0 And Divpromgral > 0 Then
    Promgral = Sumapromgral / Divpromgral
    Promgral = IIf(Len(CStr(Promgral)) = 1, Format(Promgral, ".0"), Mid(CStr(Promgral), 1, 3))
    Colorcel = IIf(Promgral < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 3: Me.Grd_rendimiento.CellForeColor = Colorcel
Else
    Promgral = "-"
End If
Me.Grd_rendimiento.TextMatrix(3, t) = Promgral

If Sumaprommax > 0 And Divprommax > 0 Then
    Prommax = Sumaprommax / Divprommax
    Prommax = IIf(Len(CStr(Prommax)) = 1, Format(Prommax, ".0"), Mid(CStr(Prommax), 1, 3))
    Colorcel = IIf(Prommax < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 4: Me.Grd_rendimiento.CellForeColor = Colorcel
Else
    Prommax = "-"
End If
Me.Grd_rendimiento.TextMatrix(4, t) = Prommax

If Sumaprommin > 0 And Divprommin > 0 Then
    Prommin = Sumaprommin / Divprommin
    Prommin = IIf(Len(CStr(Prommin)) = 1, Format(Prommin, ".0"), Mid(CStr(Prommin), 1, 3))
    Colorcel = IIf(Prommin < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Else
    Prommin = "-"
End If
Me.Grd_rendimiento.TextMatrix(5, t) = Prommin

'Colorcel = IIf(Suma6070 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(7, t) = Suma6070
    
'Colorcel = IIf(Suma5059 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(8, t) = Suma5059

'Colorcel = IIf(Suma4049 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(9, t) = Suma4049

'Colorcel = IIf(Suma3039 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(10, t) = Suma3039

'Colorcel = IIf(Suma2029 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(11, t) = Suma2029

'Colorcel = IIf(Suma1019 < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(12, t) = Suma1019

Me.Grd_rendimiento.TextMatrix(13, t) = Sumaconprom

'Colorcel = IIf(Sumasinprom < 4#, &HFF&, &HFF0000): Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 5: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(14, t) = Sumasinprom

Colorcel = &HFF&: Me.Grd_rendimiento.Col = t: Me.Grd_rendimiento.Row = 15: Me.Grd_rendimiento.CellForeColor = Colorcel
Me.Grd_rendimiento.TextMatrix(15, t) = Sumadefic
    


Form_Progress.ProgBar1.ShowProgress 0
Unload Form_Progress
End Sub

Private Sub btn_carga_grilla_oculta_rendcurso_Click()
Dim var_sql As String

Dim Indica As Boolean, Indica1 As Boolean, Indica2 As Boolean
Dim Spasig() As Single, Pasig() As Single
Dim FechaFinPer As Date, Finperiodo As Date
Dim Num_Notas_eva As Integer
    modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens ='" & Me.cmb_mod_rendcurso.Text & "'", conn)
    Finperiodo = DevuelveCampo("periodos", "", "fec_ter_per", "fec_ter_per <> '' order by fec_ter_per desc", conn)
    If UCase(Me.cmb_per_rendcurso.Text) = "ANUAL" Then
        campo = "PG"
        FechaFinPer = Finperiodo
    Else
        FechaFinPer = DevuelveCampo("periodos", "", "fec_ter_per", "num_per= '" & cmb_per_rendcurso.ListIndex & "'", conn)
        If FechaFinPer >= Finperiodo Then
            FechaFinPer = Finperiodo
        End If
        If cmb_per_rendcurso.ListIndex = 0 Then
            campo = "P1"
        ElseIf cmb_per_rendcurso.ListIndex = 1 Then
            campo = "P2"
        ElseIf cmb_per_rendcurso.ListIndex = 2 Then
            campo = "P3"
        End If
    End If
    
    Con = 0
    Fila = 1
    SelCursos = ""
    If Me.lst_niveles_rendcurso.SelCount >= 0 Then
        For t = 0 To Me.lst_niveles_rendcurso.ListCount - 1
            If Me.lst_niveles_rendcurso.Selected(t) Then
                Con = t
            End If
        Next t
        
    ' Aquí debo crear la consulta que trae los subsectores del encabezado
    ' según los niveles seleccionados
        For t = 0 To Me.lst_niveles_rendcurso.ListCount - 1
            If Me.lst_niveles_rendcurso.Selected(t) Then
                If t = Con Then
                    SelCursos = SelCursos & "s.num_gra = '" & Me.lst_niveles_rendcurso.List(t) & "'"
                    Niveles = Niveles & t + 1
                Else
                    SelCursos = SelCursos & "s.num_gra = '" & Me.lst_niveles_rendcurso.List(t) & "' or "
                    Niveles = Niveles & t + 1 & "-"
                End If '{}
            End If
        Next
        SelCursos = "(" & SelCursos & ")"
    Nsubsectores = 0
    rs.CursorLocation = adUseClient
        
    'Subsectores
    var_sql = "select distinct s.cod_asi,s.nom_asi" _
            & " from subsectores s,asi_x_cur_prof a" _
            & " where s.cod_ens = '" & modalidad & "' and " & SelCursos & " and s.ord_asi > 0" _
            & " and s.cod_sec = a.cod_sec and s.cod_asi = a.cod_asi" _
            & " and s.cod_ens = a.cod_ens and s.num_gra = a.num_gra and agno = " & val(Combo1.Text) _
            & " order by s.ord_asi"
    rs.Open var_sql, conn
    'rs.Open "select distinct cod_asi, nom_asi from subsectores where cod_ens = '" _
    '& modalidad & "' and " & SelCursos & " and ord_asi > 0 order by ord_asi", conn
        
    Nsubsectores = rs.RecordCount
    cs = 1
    Me.grd_rendcurso.Cols = Me.grd_rendcurso.Cols + Nsubsectores
    If rs.RecordCount > 0 Then
        ReDim Subsectorescurso(rs.RecordCount, 2)
        While Not rs.EOF
            Subsectorescurso(cs, 1) = rs("cod_asi") 'Lleno un arreglo con los encabezados
            Subsectorescurso(cs, 2) = rs("nom_asi") 'Lleno un arreglo con los encabezados
            Me.grd_rendcurso.ColWidth(cs + 2) = 2000
            Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 2: Me.grd_rendcurso.CellAlignment = 1
            Me.grd_rendcurso.TextMatrix(0, cs + 2) = rs("nom_asi")
            rs.MoveNext
            cs = cs + 1
        Wend
    End If
    
    rs.Close
    Me.grd_rendcurso.ColWidth(cs + 2) = 800: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 2: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 2) = "General"
    Me.grd_rendcurso.ColWidth(cs + 3) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 3: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 3) = "Más alto"
    Me.grd_rendcurso.ColWidth(cs + 4) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 4: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 4) = "Más bajo"
    Me.grd_rendcurso.ColWidth(cs + 5) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 5: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 5) = "6,0 y 7,0"
    Me.grd_rendcurso.ColWidth(cs + 6) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 6: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 6) = "5,0 y 5,9"
    Me.grd_rendcurso.ColWidth(cs + 7) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 7: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 7) = "4,0 y 4,9"
    Me.grd_rendcurso.ColWidth(cs + 8) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 8: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 8) = "3,0 y 3,9"
    Me.grd_rendcurso.ColWidth(cs + 9) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 9: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 9) = "2,0 y 2,9"
    Me.grd_rendcurso.ColWidth(cs + 10) = 800:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 10: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 10) = "1,0 y 1,9"
    Me.grd_rendcurso.ColWidth(cs + 11) = 1000:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 11: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 11) = "Sin promedio"
    Me.grd_rendcurso.ColWidth(cs + 12) = 1000:: Me.grd_rendcurso.Row = 0: Me.grd_rendcurso.Col = cs + 12: Me.grd_rendcurso.CellAlignment = 4
    Me.grd_rendcurso.TextMatrix(0, cs + 12) = "Deficientes"
    '**********************        ******************
    c = 1
    rs.CursorLocation = adUseClient
    rs.Open "select num_gra, let_cur from cursos as s where agno=" & val(Combo1.Text) & " and cod_ens ='" & modalidad & "' and " & SelCursos & " order by num_gra, let_cur", conn
        Indica1 = True
        If rs.RecordCount > 0 Then
            ReDim Cursosrend(rs.RecordCount, 3)
            While Not rs.EOF
                Cursosrend(c, 1) = rs("num_gra")
                Cursosrend(c, 2) = rs("let_cur")
                '***Inicio de detección de cambio de nivel***
                If Indica1 Then '
                    Ngrado = rs("num_gra")
                    Indica1 = False
                End If
                If rs("num_gra") <> Ngrado Then
                    Cursosrend(c - 1, 3) = "SI"
                    Ngrado = rs("num_gra")
                End If
                '***Fin detección de cambio de nivel***
                c = c + 1
                rs.MoveNext
            Wend
            Cursosrend(c - 1, 3) = "SI" ' Asigno este valor para poder tener un subtotal en el último nivel
        End If
        Ncursos = rs.RecordCount
        rs.Close
        Form_Progress.Label1.Caption = "Cargando ..."
        Form_Progress.ProgBar1.MaxValue = Ncursos
        Form_Progress.Show
              
        ' Variable de Totales a Cero
        Tcursos = 0: Tmat = 0: Pgral = 0: Divpgral = 0: Pmasalto = 0: Pmasbajo = 0: T6070 = 0: T5059 = 0: T4049 = 0: T3039 = 0: T2029 = 0: T1019 = 0: Tsinprom = 0: Tdefic = 0
        Pmasaltogral = 0: Pmasbajogral = 0:  Indica3 = True
        ' Variable de Subtotales a Cero
        ReDim Spasig(Nsubsectores, 2): ReDim Pasig(Nsubsectores, 2): Spasigxnivel = 0: Spgralxnivel = 0
        Stcursos = 0: Stmat = 0: Spgral = 0: Divspgral = 0: Spmasalto = 0: Spmasbajo = 0: St6070 = 0: St5059 = 0: St4049 = 0: St3039 = 0: St2029 = 0: St1019 = 0: Stsinprom = 0: Stdefic = 0
        Spgcurso = 0: Dpgcurso = 0
        Promediocurso = 0: Pmasaltonivel = 0: Pmasbajonivel = 0: Indica2 = True
        curso = 1
        'Me.grd_rendcurso.ColWidth(0) = 2000
        For t = 1 To Ncursos
            Spgcurso = 0: Dpgcurso = 0: Promediocurso = 0: Pgcurso = 0
            nivel = Cursosrend(t, 1)
            letra = Cursosrend(t, 2)
            Cambio = Cursosrend(t, 3)
            Me.grd_rendcurso.TextMatrix(Fila, 0) = " "
            Me.grd_rendcurso.TextMatrix(Fila, 1) = nivel & " " & letra
            'rs.CursorLocation = adUseClient: rs.Open "select count(ci_alu) from alu_x_cur where cod_ens='" & modalidad & "' and num_gra = '" & Nivel & "' and let_cur = '" & Letra & "' and ucase(activo_alu) ='SI'and fec_cam='1111-11-11'", conn
            rs.CursorLocation = adUseClient: rs.Open "select count(a.ci_alu) from alu_x_cur a, matriculas m where a.agno=" & val(Combo1.Text) & " and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and m.fec_mat=a.fec_mat and a.cod_ens ='" & modalidad & "' and a.num_gra = '" & nivel & "' and a.let_cur ='" & letra & "' and ucase(a.activo_alu)='SI' and a.fec_cam='1111-11-11' and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and a.agno = m.anno_mat", conn
            Stmat = Stmat + rs(0)
            Me.grd_rendcurso.TextMatrix(Fila, 2) = rs(0): rs.Close
            For s = 1 To Nsubsectores
                rs.CursorLocation = adUseClient:
                '########################################################
                ' AQUI SACAN LA NOTA????
                ' AQUI ESTA La MAGIA PARECE
                a = "select avg(" & campo & ") from promedios p, alu_x_cur a, matriculas m where a.agno=" & val(Combo1.Text) & " and a.agno=p.agno and p.ci_alu= a.ci_alu and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and ucase(a.activo_alu)='SI' and m.fec_mat=a.fec_mat and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and p.cod_ens=a.cod_ens and p.num_gra=a.num_gra and p.letra_curso=a.let_cur and p.cod_ens = '" & modalidad & "' and p.num_gra = '" & nivel & "' and p.letra_curso ='" & letra & "' and cod_asi = '" & Subsectorescurso(s, 1) & "' and p." & campo & " >= 1.0 and p.agno = a.agno and p.agno = m.anno_mat"
                '#
                '########################################################
                RsAux.Open a, conn: Promediocurso = RsAux(0): RsAux.Close
                If IsNull(Promediocurso) Or Promediocurso = 0 Then
                    Promediocurso = "-"
                Else
                    Promediocurso = IIf(Len(CStr(Promediocurso)) = 1, Format(Promediocurso, ".0"), Mid(CStr(Promediocurso), 1, 3))
                    Spasig(s, 1) = Spasig(s, 1) + Promediocurso
                    Spasig(s, 2) = Spasig(s, 2) + 1
                    If Trim(Subsectorescurso(s, 1)) <> "13" Then
                        Spgcurso = Spgcurso + Promediocurso
                        Dpgcurso = Dpgcurso + 1
                    End If
                    Colorcel = IIf(Promediocurso < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.CellForeColor = Colorcel
                End If
                Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4
                Me.grd_rendcurso.TextMatrix(Fila, s + 2) = Promediocurso
                
                Me.grd_rendcurso.Refresh
            Next s
            
            If Spgcurso > 0 And Dpgcurso > 0 Then
                Pgcurso = Spgcurso / Dpgcurso
                Pgcurso = IIf(Len(CStr(Pgcurso)) = 1, Format(Pgcurso, ".0"), Mid(CStr(Pgcurso), 1, 3))
                Colorcel = IIf(Pgcurso < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellForeColor = Colorcel
                Spgral = Spgral + Pgcurso
                Divspgral = Divspgral + 1
            Else
                Pgcurso = "-"
            End If
            Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4
            Me.grd_rendcurso.TextMatrix(Fila, s + 2) = Pgcurso '''''''
            
            'rs.CursorLocation = adUseClient: rs.Open "select ci_alu from alu_x_cur where cod_ens='" & modalidad & "' and num_gra = '" & Nivel & "' and let_cur = '" & Letra & "' and ucase(activo_alu) ='SI'", conn
            rs.CursorLocation = adUseClient: rs.Open "select a.ci_alu from alu_x_cur a, matriculas m where a.agno=" & val(Combo1.Text) & " and a.ci_alu=m.ci_alu and m.activo_alu=a.activo_alu and m.fec_mat=a.fec_mat and a.cod_ens ='" & modalidad & "' and a.num_gra = '" & nivel & "' and a.let_cur ='" & letra & "' and ucase(a.activo_alu)='SI' and a.fec_cam='1111-11-11' and m.fec_mat <= '" & Format(FechaFinPer, "yyyy-mm-dd") & "' and a.agno = m.anno_mat", conn
            A1019 = 0: A2029 = 0: A3039 = 0: A4049 = 0: A5059 = 0: A6070 = 0
            
            Pmasalto = 0: Pmasbajo = 0: Indica = True
            If rs.RecordCount > 0 Then
                For ii = 1 To rs.RecordCount
                    pgalumno = 0
                    rutalumno = rs("ci_alu")
                    RsAux.CursorLocation = adUseClient
                    RsAux.Open "select avg(" & campo & ") from promedios where cod_asi<>13 and agno=" & val(Combo1.Text) & " and ci_alu = '" & rutalumno & "' and " & campo & " >= 1.0", conn
                    pgalumno = RsAux(0)
                    RsAux.Close
                    If pgalumno >= Pmasalto Then Pmasalto = pgalumno
                    If Indica And pgalumno <> 0 Then
                        Pmasbajo = pgalumno
                        Indica = False
                    End If
                    If pgalumno < Pmasbajo And pgalumno <> "-" Then Pmasbajo = pgalumno
                                 
                    If pgalumno >= 1# And pgalumno < 2# Then
                        A1019 = A1019 + 1: St1019 = St1019 + 1
                    ElseIf pgalumno >= 2# And pgalumno < 3# Then
                        A2029 = A2029 + 1: St2029 = St2029 + 1
                    ElseIf pgalumno >= 3# And pgalumno < 4# Then
                        A3039 = A3039 + 1: St3039 = St3039 + 1
                    ElseIf pgalumno >= 4# And pgalumno < 5# Then
                        A4049 = A4049 + 1: St4049 = St4049 + 1
                    ElseIf pgalumno >= 5# And pgalumno < 6# Then
                        A5059 = A5059 + 1: St5059 = St5059 + 1
                    ElseIf pgalumno >= 6# And pgalumno <= 7# Then
                        A6070 = A6070 + 1: St6070 = St6070 + 1
                    ElseIf IsNull(pgalumno) Then
                        MsgBox "Alumno RUT " & rutalumno & " SIN NOTAS ESTE SEMESTRE", vbExclamation, "ATENCIÓN"
                    Else
                        MsgBox "promedio " & pgalumno & " fuera de rango para alumno " & rutalumno, vbExclamation, "ATENCIÓN"
                    End If
                    rs.MoveNext
                Next ii
            End If
            rs.Close
            If IsNull(Pmasalto) Or Pmasalto = 0 Then
                Pmasalto = "-"
            Else
                Pmasalto = IIf(Len(CStr(Pmasalto)) = 1, Format(Pmasalto, ".0"), Mid(CStr(Pmasalto), 1, 3))
                Colorcel = IIf(Pmasalto < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.CellForeColor = Colorcel
            End If
            If IsNull(Pmasbajo) Or Pmasbajo = 0 Then
                Pmasbajo = "-"
            Else
                Pmasbajo = IIf(Len(CStr(Pmasbajo)) = 1, Format(Pmasbajo, ".0"), Mid(CStr(Pmasbajo), 1, 3))
                Colorcel = IIf(Pmasbajo < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.CellForeColor = Colorcel
            End If
            Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 3) = Pmasalto ''''''
            Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 4) = Pmasbajo ''''''
            If Pmasalto >= Pmasaltonivel Then Pmasaltonivel = Pmasalto
            If Indica2 And Pmasbajo <> "-" Then
                Pmasbajonivel = Pmasbajo
                Indica2 = False
            End If
            If Pmasbajo < Pmasbajonivel And Pmasbajo <> "-" Then Pmasbajonivel = Pmasbajo
            
            Me.grd_rendcurso.Col = s + 5: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 5) = A6070 '''''''
            Me.grd_rendcurso.Col = s + 6: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 6) = A5059 '''''''
            Me.grd_rendcurso.Col = s + 7: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 7) = A4049 '''''''
            Me.grd_rendcurso.Col = s + 8: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.CellForeColor = &HFF&: Me.grd_rendcurso.TextMatrix(Fila, s + 8) = A3039 '''''''
            Me.grd_rendcurso.Col = s + 9: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.CellForeColor = &HFF&: Me.grd_rendcurso.TextMatrix(Fila, s + 9) = A2029 '''''''
            Me.grd_rendcurso.Col = s + 10: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.CellForeColor = &HFF&: Me.grd_rendcurso.TextMatrix(Fila, s + 10) = A1019 '''''''
            Sinprom = val(Me.grd_rendcurso.TextMatrix(Fila, 2)) - (val(Me.grd_rendcurso.TextMatrix(Fila, s + 5)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 6)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 7)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 8)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 9)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 10)))
            Stsinprom = Stsinprom + Sinprom
            Defic = val(Me.grd_rendcurso.TextMatrix(Fila, s + 8)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 9)) + val(Me.grd_rendcurso.TextMatrix(Fila, s + 10))
            Stdefic = Stdefic + Defic
            Me.grd_rendcurso.Col = s + 11: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 11) = Sinprom
            Me.grd_rendcurso.Col = s + 12: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.CellForeColor = &HFF&: Me.grd_rendcurso.TextMatrix(Fila, s + 12) = Defic
            
            Me.grd_rendcurso.Rows = Me.grd_rendcurso.Rows + 1
            Fila = Fila + 1
            If Cambio = "SI" Then
                Me.grd_rendcurso.TextMatrix(Fila, 0) = "Total nivel"
                Me.grd_rendcurso.TextMatrix(Fila, 1) = curso
                Me.grd_rendcurso.TextMatrix(Fila, 2) = Stmat: Tmat = Tmat + Stmat
                For j = 1 To Nsubsectores
                    If Spasig(j, 1) > 0 And Spasig(j, 2) > 0 Then
                        Spasigxnivel = Spasig(j, 1) / Spasig(j, 2)
                        Spasigxnivel = IIf(Len(CStr(Spasigxnivel)) = 1, Format(Spasigxnivel, ".0"), Mid(CStr(Spasigxnivel), 1, 4))
                        Colorcel = IIf(Spasigxnivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Col = 2 + j: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellForeColor = Colorcel
                        Pasig(j, 1) = Pasig(j, 1) + Spasigxnivel
                        Pasig(j, 2) = Pasig(j, 2) + 1
                    Else
                        Spasigxnivel = "-"
                    End If
                    Me.grd_rendcurso.Col = 2 + j: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4
                    Me.grd_rendcurso.TextMatrix(Fila, 2 + j) = Spasigxnivel
                Next j
                If Spgral > 0 And Divspgral > 0 Then
                    Spgralxnivel = Spgral / Divspgral
                    Spgralxnivel = IIf(Len(CStr(Spgralxnivel)) = 1, Format(Spgralxnivel, ".0"), Mid(CStr(Spgralxnivel), 1, 4))
                    Colorcel = IIf(Spgralxnivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellForeColor = Colorcel
                    Pgral = Pgral + Spgralxnivel
                    Divpgral = Divpgral + 1
                Else
                    Spgralxnivel = "-"
                End If
                         
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 2) = Spgralxnivel
                
                If IsNull(Pmasaltonivel) Or Pmasaltonivel = 0 Then
                    Pmasaltonivel = "-"
                Else
                    Pmasaltonivel = IIf(Len(CStr(Pmasaltonivel)) = 1, Format(Pmasaltonivel, ".0"), Mid(CStr(Pmasaltonivel), 1, 3))
                    Colorcel = IIf(Pmasaltonivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.CellForeColor = Colorcel
                End If
                
                If IsNull(Pmasbajonivel) Or Pmasbajonivel = 0 Then
                    Pmasbajonivel = "-"
                Else
                    Pmasbajonivel = IIf(Len(CStr(Pmasbajonivel)) = 1, Format(Pmasbajonivel, ".0"), Mid(CStr(Pmasbajonivel), 1, 3))
                    Colorcel = IIf(Pmasbajonivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.CellForeColor = Colorcel
                End If
                
                If Pmasaltonivel >= Pmasaltogral Then Pmasaltogral = Pmasaltonivel
                
                If Indica3 And Pmasbajonivel <> "-" Then
                    Pmasbajogral = Pmasbajonivel
                    Indica3 = False
                End If
                If Pmasbajonivel < Pmasbajogral And Pmasbajonivel <> "-" Then Pmasbajogral = Pmasbajonivel
                
                
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 3) = Pmasaltonivel
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 4) = Pmasbajonivel
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 5: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 5) = St6070: T6070 = T6070 + St6070
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 6: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 6) = St5059: T5059 = T5059 + St5059
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 7: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 7) = St4049: T4049 = T4049 + St4049
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 8: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 8) = St3039: T3039 = T3039 + St3039
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 9: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 9) = St2029: T2029 = T2029 + St2029
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 10: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 10) = St1019: T1019 = T1019 + St1019
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 11: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 11) = Stsinprom: Tsinprom = Tsinprom + Stsinprom
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 12: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 12) = Stdefic: Tdefic = Tdefic + Stdefic
                 
                ReDim Spasig(Nsubsectores, 2)
                Spasigxnivel = 0: Spgralxnivel = 0
                Stcursos = 0: Stmat = 0: Spgral = 0: Divspgral = 0: Spmasalto = 0: Spmasbajo = 0: St6070 = 0: St5059 = 0: St4049 = 0: St3039 = 0: St2029 = 0: St1019 = 0: Stsinprom = 0: Stdefic = 0
                Spgcurso = 0: Dpgcurso = 0: Pmasaltonivel = 0: Pmasbajonivel = 0: Indica2 = True
                curso = 0
                
                Me.grd_rendcurso.Rows = Me.grd_rendcurso.Rows + 2
                For p = 2 To Me.grd_rendcurso.Cols - 1
                    Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = p: Me.grd_rendcurso.CellBackColor = &H8000000F
                Next p
                Fila = Fila + 2
            End If
        Form_Progress.ProgBar1.ShowProgress t
        Form_Progress.SetFocus
        DoEvents
        curso = curso + 1
        Next t
                ' Aquí van los totales
        For p = 2 To Me.grd_rendcurso.Cols - 1
               Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = p: Me.grd_rendcurso.CellBackColor = &H8000000F
            Next p
            Me.grd_rendcurso.TextMatrix(Fila, 0) = "Total colegio"
            Me.grd_rendcurso.TextMatrix(Fila, 1) = Ncursos ' aqui van la cantidad de cursos del nivel.
            Me.grd_rendcurso.TextMatrix(Fila, 2) = Tmat ' aqui van la totalidad de los cursos del informe
            For j = 1 To Nsubsectores
                If Pasig(j, 1) > 0 And Pasig(j, 2) > 0 Then
                    Pasigxnivel = Pasig(j, 1) / Pasig(j, 2)
                    Pasigxnivel = IIf(Len(CStr(Pasigxnivel)) = 1, Format(Pasigxnivel, ".0"), Mid(CStr(Pasigxnivel), 1, 4))
                    Colorcel = IIf(Pasigxnivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Col = 2 + j: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellForeColor = Colorcel
                Else
                    Pasigxnivel = "-"
                End If
                Me.grd_rendcurso.Col = 2 + j: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4
                Me.grd_rendcurso.TextMatrix(Fila, 2 + j) = Pasigxnivel
            Next j
                If Pgral > 0 And Divpgral > 0 Then
                    Pgralxnivel = Pgral / Divpgral
                    Pgralxnivel = IIf(Len(CStr(Pgralxnivel)) = 1, Format(Pgralxnivel, ".0"), Mid(CStr(Pgralxnivel), 1, 4))
                    Colorcel = IIf(Pgralxnivel < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellForeColor = Colorcel
                Else
                    Pgralxnivel = "-"
                End If
                Me.grd_rendcurso.Col = s + 2: Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.CellAlignment = 4
                Me.grd_rendcurso.TextMatrix(Fila, s + 2) = Pgralxnivel
                
                If IsNull(Pmasaltogral) Or Pmasaltogral = 0 Then
                    Pmasaltogral = "-"
                Else
                    Pmasaltogral = IIf(Len(CStr(Pmasaltogral)) = 1, Format(Pmasaltogral, ".0"), Mid(CStr(Pmasaltogral), 1, 3))
                    Colorcel = IIf(Pmasaltogral < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.CellForeColor = Colorcel
                End If
                
                If IsNull(Pmasbajogral) Or Pmasbajogral = 0 Then
                    Pmasbajogral = "-"
                Else
                    Pmasbajogral = IIf(Len(CStr(Pmasbajogral)) = 1, Format(Pmasbajogral, ".0"), Mid(CStr(Pmasbajogral), 1, 3))
                    Colorcel = IIf(Pmasbajogral < 4#, &HFF&, &HFF0000): Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.CellForeColor = Colorcel
                End If
                                
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 3: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 3) = Pmasaltogral
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 4: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 4) = Pmasbajogral
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 5: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 5) = T6070
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 6: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 6) = T5059
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 7: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 7) = T4049
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 8: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 8) = T3039
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 9: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 9) = T2029
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 10: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 10) = T1019
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 11: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 11) = Tsinprom
                Me.grd_rendcurso.Row = Fila: Me.grd_rendcurso.Col = s + 12: Me.grd_rendcurso.CellAlignment = 4: Me.grd_rendcurso.TextMatrix(Fila, s + 12) = Tdefic
    End If
    Form_Progress.ProgBar1.ShowProgress 0
    Unload Form_Progress
End Sub

Private Sub Btn_gen_Rep_Rendcurso_Click()
'On Error GoTo Errorimpresion
Call CreaBD(DirAplicacion & "\GesTemp.mdb")
Set Rendcurso = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur1", "30,10") ' promedios
'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur2", "26,10") ' subsectores
'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur3", "13,10") ' estadisticas

'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur1", "44,10") ' promedios
'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur2", "38,10") ' subsectores
'Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur3", "24,10") ' estadisticas

Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur1", "70,10") ' promedios
Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur2", "60,10") ' subsectores
Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Pan_cur3", "50,10") ' estadisticas

infoprimera = Nsubsectores + 2
detal = "": ins = ""
For c = 3 To infoprimera
    If Me.grd_rendcurso.TextMatrix(0, c) = "" Then
        detal = detal & "Null , "
    Else
        detal = detal & "'" & Me.grd_rendcurso.TextMatrix(0, c) & "' , "
    End If
    ins = ins & "C" & CStr(c - 2) & ", "
Next c
ins = Left(ins, Len(ins) - 2)
ins = "(" & ins & ")"
detal = Left(detal, Len(detal) - 2): detal = "(" & detal & ")"
a = "insert into Pan_cur2 " & ins & " values " & detal
Rendcurso.Execute a
'sql1 = " insert into fichas (Cod_beca, Rut_alumno, folio, nombres, ap_paterno, ap_materno, curso, domicilio, fecha_ficha, prom1s, pnt_notas, pnt_notashnos, cod_jefehogar, pnt_jefehogar, cod_sitlaboral, n_integrantes, ingresosfam, pnt_econom, cod_vivienda, montovivienda, pnt_vivienda, cod_enferm1, cod_enferm2, cod_enferm3, cod_enferm4, pnt_enferm, pnt_total, estado)"
'sql2 = "values (" & "'" & CAMPO1 & "'" & "," & "'" & CAMPO2 & "'" & "," & "'" & campo3 & "'" & "," & "'" & campo4 & "'" & "," & "'" & campo5 & "'" & "," & "'" & campo6 & "'" & "," & "'" & campo7 & "'" & "," & "'" & campo8 & "'" & "," & "'" & campo9 & "'" & "," & "'" & campo10 & "'" & "," & "'" & campo11 & "'" & "," & "'" & campo12 & "'" & "," & "'" & campo13 & "'" & "," & "'" & campo14 & "'" & "," & "'" & campo15 & "'" & "," & "'" & campo16 & "'" & "," & "'" & campo17 & "'" & "," & "'" & campo18 & "'" & "," & "'" & campo19 & "'" & "," & "'" & campo20 & "'" & "," & "'" & campo21 & "'" & "," & "'" & campo22 & "'" & "," & "'" & campo23 & "'" & "," & "'" & campo24 & "'" & "," & "'" & campo25 & "'" & "," & "'" & campo26 & "'" & "," & "'" & campo27 & "'" & "," & "'" & campo28 & "'" & ")"
'sql3 = sql1 + sql2

For R = 1 To Me.grd_rendcurso.Rows - 1
    detal = "": ins = "": horiz = ""
    For t = 0 To 1
        'If Me.grd_rendcurso.TextMatrix(R, t) = "-" Or
        If Me.grd_rendcurso.TextMatrix(R, t) = "" Then
            detal = detal & "Null , "
        Else
            detal = detal & "'" & Me.grd_rendcurso.TextMatrix(R, t) & "' , "
        End If
        ins = ins & "C" & CStr(t + 1) & ", "
    Next t
    For t = 2 To infoprimera
        'If Me.grd_rendcurso.TextMatrix(R, t) = "-" Or
        If Me.grd_rendcurso.TextMatrix(R, t) = "" Then
            detal = detal & "Null , "
        Else
            detal = detal & "'" & Me.grd_rendcurso.TextMatrix(R, t) & "' , "
        End If
        ins = ins & "C" & CStr(t + 1) & ", "
    Next t
    Columna = infoprimera + 1
    For te = t + 1 To 25 '+1  probando aqui
        detal = detal & "Null , "
        ins = ins & "C" & CStr(te) & ", "
    Next te
    
    If Me.grd_rendcurso.TextMatrix(R, Columna) = "" Then
        detal = detal & "Null , "
    Else
        detal = detal & "'" & Me.grd_rendcurso.TextMatrix(R, Columna) & "' , "
    End If
    ins = ins & "C60, "
    ins = Left(ins, Len(ins) - 2): ins = "(" & ins & ")"
    detal = Left(detal, Len(detal) - 2): detal = "(" & detal & ")"
    a = "insert into Pan_cur1 " & ins & " values " & detal
    Rendcurso.Execute a
Next R
    
For R = 1 To Me.grd_rendcurso.Rows - 1
    detal = "": ins = ""
    Columna = 0
    For Col = 1 To 3
        If Me.grd_rendcurso.TextMatrix(R, Columna) = "" Then
            detal = detal & "Null , "
        Else
            detal = detal & "'" & Me.grd_rendcurso.TextMatrix(R, Columna) & "' , "
        End If
        ins = ins & "C" & CStr(Col) & ", "
        Columna = Columna + 1
    Next Col
    
    Columna = infoprimera + 2
    For t = 4 To 13
        'If Me.grd_rendcurso.TextMatrix(R, Columna) = "-" Or
        If Me.grd_rendcurso.TextMatrix(R, Columna) = "" Then
            detal = detal & "Null , "
        Else
            detal = detal & "'" & Me.grd_rendcurso.TextMatrix(R, Columna) & "' , "
        End If
        ins = ins & "C" & CStr(t) & ", "
        Columna = Columna + 1
    Next t
    ins = Left(ins, Len(ins) - 2): ins = "(" & ins & ")"
    detal = Left(detal, Len(detal) - 2): detal = "(" & detal & ")"
    a = "insert into Pan_cur3 " & ins & " values " & detal
    Rendcurso.Execute a
Next R
    Rendcurso.Close
    titulo = "RENDIMIENTO CURSOS " & Me.cmb_per_rendcurso.Text & " PERÍODO ESCOLAR " & val(Combo1.Text)
    Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(0) = "Nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "Dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "Comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "Titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "Hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "Tipens= '" & Me.cmb_mod_rendcurso.Text & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Rend_Curso.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Action = 1
    'Call LimpiaFormulas(Form_main.CrystalReport, 30)
    titulo = "ESTADÍSTICAS DE RENDIMIENTO " & Me.cmb_per_rendcurso.Text & " PERÍODO ESCOLAR " & val(Combo1.Text)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(3) = "Titulo= '" & titulo & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Rend_Curso2.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Action = 1
  
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
  
  '  Kill (DirAplicacion & "\GesTemp.mdb")
Exit Sub
Errorimpresion:
If Err.Number = 20513 Then
    MsgBox ("Hubo problemas al imprimir")
Else
    MsgBox (Err.Number & " " & Err.Description)
End If
End Sub

Private Sub btn_gen_reporte_Click()
Call CreaBD(DirAplicacion & "\GesTemp.mdb")
columnasnum = Me.Grd_rendimiento.Cols
Set Rendim = DBEngine.Workspaces(0).OpenDatabase(DirAplicacion & "\GesTemp.mdb")
Call CreaTabla(DirAplicacion & "\GesTemp.mdb", "Detalles", "29,10")
 Infosinresumen = (Me.Grd_rendimiento.Cols - 1) - 3
'sql1 = " insert into fichas (Cod_beca, Rut_alumno, folio, nombres, ap_paterno, ap_materno, curso, domicilio, fecha_ficha, prom1s, pnt_notas, pnt_notashnos, cod_jefehogar, pnt_jefehogar, cod_sitlaboral, n_integrantes, ingresosfam, pnt_econom, cod_vivienda, montovivienda, pnt_vivienda, cod_enferm1, cod_enferm2, cod_enferm3, cod_enferm4, pnt_enferm, pnt_total, estado)"
'sql2 = "values (" & "'" & CAMPO1 & "'" & "," & "'" & CAMPO2 & "'" & "," & "'" & campo3 & "'" & "," & "'" & campo4 & "'" & "," & "'" & campo5 & "'" & "," & "'" & campo6 & "'" & "," & "'" & campo7 & "'" & "," & "'" & campo8 & "'" & "," & "'" & campo9 & "'" & "," & "'" & campo10 & "'" & "," & "'" & campo11 & "'" & "," & "'" & campo12 & "'" & "," & "'" & campo13 & "'" & "," & "'" & campo14 & "'" & "," & "'" & campo15 & "'" & "," & "'" & campo16 & "'" & "," & "'" & campo17 & "'" & "," & "'" & campo18 & "'" & "," & "'" & campo19 & "'" & "," & "'" & campo20 & "'" & "," & "'" & campo21 & "'" & "," & "'" & campo22 & "'" & "," & "'" & campo23 & "'" & "," & "'" & campo24 & "'" & "," & "'" & campo25 & "'" & "," & "'" & campo26 & "'" & "," & "'" & campo27 & "'" & "," & "'" & campo28 & "'" & ")"
'sql3 = sql1 + sql2
For R = 0 To Me.Grd_rendimiento.Rows - 1
    detal = "": ins = "": horiz = ""
    For t = 0 To Infosinresumen
        If Me.Grd_rendimiento.TextMatrix(R, t) = "" Then
            detal = detal & "Null , "
            'horiz = horiz & "'____________________________________' ,"
        Else
            detal = detal & "'" & Me.Grd_rendimiento.TextMatrix(R, t) & "' , "
            'horiz = horiz & "'____________________________________' ,"
        End If
        ins = ins & "C" & CStr(t + 1) & ", "
    Next t
    For t = Infosinresumen + 1 To 22
        'If Me.Grd_rendimiento.TextMatrix(R, t) = "" Then
            detal = detal & "Null , "
            'horiz = horiz & "'____________________________________' ,"
        'Else
         '   detal = detal & "'" & Me.Grd_rendimiento.TextMatrix(R, t) & "' , "
            'horiz = horiz & "'____________________________________' ,"
        'End If
        
        ins = ins & "C" & CStr(t + 1) & ", "
    Next t
    'Infosinresumen + 1 To Infosinresumen + 3
    Columna = Infosinresumen + 1
    For t = 24 To 26
        If Me.Grd_rendimiento.TextMatrix(R, Columna) = "" Then
            detal = detal & "Null , "
            'horiz = horiz & "'____________________________________' ,"
        Else
            detal = detal & "'" & Me.Grd_rendimiento.TextMatrix(R, Columna) & "' , "
            'horiz = horiz & "'____________________________________' ,"
        End If
        ins = ins & "C" & CStr(t) & ", "
        Columna = Columna + 1
    Next t
    ins = Left(ins, Len(ins) - 2): ins = "(" & ins & ")"
    detal = Left(detal, Len(detal) - 2): detal = "(" & detal & ")"
    'horiz = Left(horiz, Len(horiz) - 2): horiz = "(" & horiz & ")"
    a = "insert into Detalles " & ins & " values " & detal
    Rendim.Execute a

Next R
Rendim.Close
    titulo = "RENDIMIENTO POR PROFESOR " & periodo & " AÑO " & cb_agno.Text
    Nombrecol = DevuelveCampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = DevuelveCampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = DevuelveCampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = titulo
    Form_main.CrystalReport.Formulas(0) = "nombrecolegio = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "direccioncolegio = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacolegio = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.Formulas(5) = "Nombreprofe= '" & Profesor & "'"
    Form_main.CrystalReport.Formulas(6) = "Subsector= '" & Subsector & "'"
    Form_main.CrystalReport.Formulas(7) = "Periodo = '" & periodo & "'"
    'Form_main.CrystalReport.Formulas(8) = "niveles = '" & niveles & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\Rend_Prof.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\GesTemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 30)
    Kill (DirAplicacion & "\GesTemp.mdb")
    
End Sub

Private Sub Btn_Limpiar_Click()
If Me.Opt_profeasig(0) Then
    Me.Opt_profeasig(0).Value = False
    Me.Opt_profeasig(0).Value = True
ElseIf Me.Opt_profeasig(1) Then
    Me.Opt_profeasig(1).Value = False
    Me.Opt_profeasig(1).Value = True
End If
End Sub

Private Sub Btn_limpiar_Rendcurso_Click()
Me.Btn_gen_Rep_Rendcurso.Enabled = False
Me.cmb_mod_rendcurso.Text = ""
Me.lst_niveles_rendcurso.Clear
Me.cmb_per_rendcurso.Text = ""
Call Grillainicial2
End Sub

Private Sub cb_agno_Click()
'    If Opt_profeasig(1).Value = True Then
'        cmb_asig_impart_Click
'    End If
'    If Opt_profeasig(0).Value = True Then
'        cmb_profes_asig_Click
'    End If
Btn_Limpiar_Click
End Sub

Private Sub chk_todos_niveles_rendcurso_Click()
If Me.chk_todos_niveles_rendcurso.Value Then
    For t = 0 To Me.lst_niveles_rendcurso.ListCount - 1
        Me.lst_niveles_rendcurso.Selected(t) = True
    Next t
Else
    For t = 0 To Me.lst_niveles_rendcurso.ListCount - 1
        Me.lst_niveles_rendcurso.Selected(t) = False
        Me.lst_niveles_rendcurso.ListIndex = 0
    Next t
End If

End Sub

Private Sub cmb_asig_exist_Click()
Subsector = Me.cmb_asig_exist.Text
Me.Btn_Gen_Reporte.Enabled = False
Me.cmb_profes_asig.Clear
'MsgBox (Subsectoresi(Me.cmb_asig_exist.ListIndex, 1) & " " & Subsectoresi(Me.cmb_asig_exist.ListIndex, 2))
Codsec = Subsectoresi(Me.cmb_asig_exist.ListIndex, 1)
Codasi = Subsectoresi(Me.cmb_asig_exist.ListIndex, 2)
'OJO PORQUE SE ORDENA MEDIANTE EL CODIGO DE LA ENSEÑANZA
'O SEA QUE SI EL CODIGO DE LA MEDIA PASA A SER MENOR QUE LA BASICA(110)
'QUEDARIA ANTES EN EL INFORME........AGREGAR INDICE PUEDE SER UNA SOLUCION!!!!!
rs.CursorLocation = adUseClient
rs.Open "select distinct rut_prof from asi_x_cur_prof  where cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and agno = " & cb_agno.Text, conn
c = 0
If rs.RecordCount > 0 Then
    ReDim aprofesores(rs.RecordCount)
    While Not rs.EOF
        aprofesores(c) = rs("rut_prof")
        RsAux.CursorLocation = adUseClient: RsAux.Open "select ape1_prof, ape2_prof, noms_prof from profesores where rut_prof ='" & rs("rut_prof") & "'", conn
        If rs.RecordCount > 0 Then
            Me.cmb_profes_asig.AddItem RsAux("ape1_prof") & " " & RsAux("ape2_prof") & " " & RsAux("noms_prof")
        End If
        RsAux.Close
        rs.MoveNext
        c = c + 1
    Wend
End If
rs.Close

End Sub

Private Sub cmb_asig_exist_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_asig_impart_Click()
Subsector = Me.cmb_asig_impart.Text
Me.Btn_Gen_Reporte.Enabled = False
Me.cmb_Periodo_Prof.Clear
Call LlenaCombo(cmb_Periodo_Prof, "Periodos", "des_per", "order by num_per", conn)
If Me.cmb_Periodo_Prof.ListCount > 0 Then
    Me.cmb_Periodo_Prof.AddItem "ANUAL"
End If
'MsgBox (Subsectoresi(Me.cmb_asig_impart.ListIndex, 1) & " " & Subsectoresi(Me.cmb_asig_impart.ListIndex, 2))
Codsec = Subsectoresi(Me.cmb_asig_impart.ListIndex, 1)
Codasi = Subsectoresi(Me.cmb_asig_impart.ListIndex, 2)
'OJO PORQUE SE ORDENA MEDIANTE EL CODIGO DE LA ENSEÑANZA
'O SEA QUE SI EL CODIGO DE LA MEDIA PASA A SER MENOR QUE LA BASICA(110)
'QUEDARIA ANTES EN EL INFORME........AGREGAR INDICE!!!!!
rs.CursorLocation = adUseClient
rs.Open "select cod_ens, num_gra, let_cur from  asi_x_cur_prof  where rut_prof ='" & RutProfe & "'and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and agno = " & cb_agno.Text & " order by cod_ens, num_gra, let_cur asc"
'rs.Open "select cod_ens, num_gra, let_cur from  asi_x_cur_prof  where rut_prof ='" & RutProfe & "'and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' order by cod_ens, num_gra, let_cur asc"
c = 0
If rs.RecordCount > 0 Then
    ReDim Cursosimpartidos(rs.RecordCount, 3)
    Totalcursos = rs.RecordCount
    While Not rs.EOF
        'MsgBox (rs("cod_ens") & " " & rs("num_gra") & " " & rs("let_cur"))
        Cursosimpartidos(c, 1) = rs("cod_ens")
        Cursosimpartidos(c, 2) = rs("num_gra")
        Cursosimpartidos(c, 3) = rs("let_cur")
        rs.MoveNext
        c = c + 1
    Wend
Else
    Totalcursos = 0
End If
rs.Close
End Sub

Private Sub cmb_asig_impart_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub cmb_mod_rendcurso_Click()
Me.chk_todos_niveles_rendcurso.Enabled = True
Me.chk_todos_niveles_rendcurso.Value = 0
modalidad = DevuelveCampo("codigos_ensenanza", "", "cod_ens", "des_ens = '" & Me.cmb_mod_rendcurso.Text & "'", conn)
rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM codigos_ensenanza where cod_ens ='" & modalidad & "'", conn
If rs.RecordCount > 0 Then
    Me.lst_niveles_rendcurso.Clear
    For t = 1 To val(rs("num_gra_max"))
        lst_niveles_rendcurso.AddItem t
    Next t
    Me.chk_todos_niveles_rendcurso.Enabled = True
Else
    Me.chk_todos_niveles_rendcurso.Enabled = False
End If
rs.Close
Me.cmb_per_rendcurso.Text = ""
Call Grillainicial2
Me.Btn_gen_Rep_Rendcurso.Enabled = False
End Sub
Private Sub cmb_numgra_rendcurso_Change()

End Sub

Private Sub cmb_numgra_rendcurso_Click()
End Sub

Private Sub cmb_mod_rendcurso_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_per_rendcurso_Click()
If Me.cmb_mod_rendcurso <> "" And Me.lst_niveles_rendcurso.SelCount > 0 Then
    Call Grillainicial2
    Me.Btn_gen_Rep_Rendcurso.Enabled = False
    Call btn_carga_grilla_oculta_rendcurso_Click
    Me.Btn_gen_Rep_Rendcurso.Enabled = True
Else
    MsgBox ("Faltan opciones importantes por seleccionar")
End If

End Sub

Private Sub cmb_per_rendcurso_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_Periodo_Prof_Click()
periodo = Me.cmb_Periodo_Prof.Text
If Me.cmb_asig_impart.Text <> "" And Me.txt_nom_asi_prof.Text <> "" Then
    Me.Btn_Gen_Reporte.Enabled = True
    'Codperiodo = devuelvecampo("Periodos", "", "num_per", "des_per = '" & Me.cmb_Periodo_Prof.Text & "'")
    If UCase(Me.cmb_Periodo_Prof.Text) = "ANUAL" Then
        IndicePeriodo = -1
    Else
        IndicePeriodo = Me.cmb_Periodo_Prof.ListIndex
    End If
    Call Btn_Carga_grilla_oculta_Click
Else
    MsgBox ("Faltan campos importantes por seleccionar")
End If
End Sub

Private Sub cmb_Periodo_Prof_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_Periodo_subsec_Click()
periodo = Me.cmb_Periodo_subsec.Text
If Me.cmb_asig_exist <> "" And Me.cmb_profes_asig.Text <> "" Then
    Me.Btn_Gen_Reporte.Enabled = True
    'Codperiodo = devuelvecampo("Periodos", "", "num_per", "des_per = '" & Me.cmb_Periodo_subsec.Text & "'")
    If UCase(Me.cmb_Periodo_subsec.Text) = "ANUAL" Then
        IndicePeriodo = -1
    Else
        IndicePeriodo = Me.cmb_Periodo_subsec.ListIndex
    End If
    Call Btn_Carga_grilla_oculta_Click
Else
    MsgBox ("Faltan campos importantes por seleccionar")
End If
End Sub

Private Sub cmb_Periodo_subsec_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub cmb_profes_asig_Click()
Profesor = Me.cmb_profes_asig.Text
Me.Btn_Gen_Reporte.Enabled = False
Me.cmb_Periodo_subsec.Clear
Call LlenaCombo(cmb_Periodo_subsec, "Periodos", "des_per", "order by num_per", conn)
If Me.cmb_Periodo_subsec.ListCount > 0 Then
    Me.cmb_Periodo_subsec.AddItem "ANUAL"
End If
RutProfe = aprofesores(Me.cmb_profes_asig.ListIndex)
Codsec = Subsectoresi(Me.cmb_asig_exist.ListIndex, 1)
Codasi = Subsectoresi(Me.cmb_asig_exist.ListIndex, 2)

'OJO PORQUE SE ORDENA MEDIANTE EL CODIGO DE LA ENSEÑANZA
'O SEA QUE SI EL CODIGO DE LA MEDIA PASA A SER MENOR QUE LA BASICA(110)
'QUEDARIA ANTES EN EL INFORME........AGREGAR INDICE!!!!!
rs.CursorLocation = adUseClient
rs.Open "select cod_ens, num_gra, let_cur from  asi_x_cur_prof  where rut_prof ='" & RutProfe & "'and cod_sec = '" & Codsec & "' and cod_asi = '" & Codasi & "' and agno = " & cb_agno.Text & " order by cod_ens, num_gra, let_cur asc"
c = 0
If rs.RecordCount > 0 Then
    ReDim Cursosimpartidos(rs.RecordCount, 3)
    Totalcursos = rs.RecordCount
    While Not rs.EOF
        'MsgBox (rs("cod_ens") & " " & rs("num_gra") & " " & rs("let_cur"))
        Cursosimpartidos(c, 1) = rs("cod_ens")
        Cursosimpartidos(c, 2) = rs("num_gra")
        Cursosimpartidos(c, 3) = rs("let_cur")
        rs.MoveNext
        c = c + 1
    Wend
Else
    Totalcursos = 0
End If
rs.Close

'MsgBox (Rutprofe)
'MsgBox (Subsectoresi(Me.cmb_asig_exist.ListIndex, 1) & " " & Subsectoresi(Me.cmb_asig_exist.ListIndex, 2))
End Sub

Private Sub cmb_profes_asig_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

Private Sub Combo1_Click()
    If cmb_per_rendcurso.Text <> "" Then
        Call cmb_per_rendcurso_Click
    End If
End Sub


Private Sub Form_Load()
If Menuinformes3 = "rendimientoprof" Then
    llena_combo_agno
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Call Form_main.hideframeimpresion3
    Me.Height = 8000
    Me.Width = 11150
    Me.Frame_Rendimientoprofes.Top = 120
    Me.Frame_Rendimientoprofes.Left = 129
    Me.Frame_Rendimientoprofes.Visible = True
    Me.Grd_rendimiento.FormatString = "               ;Tipo de enseñanza|Cursos que atiende|Matrícula|Promedio del Curso|Promedio más alto|Promedio más bajo|Distribución alumnos por rango|Entre 6,0 y 7,0|Entre 5,0 y 5,9|Entre 4,0 y 4,9|Entre 3,0 y 3,9|Entre 2,0 y 2,9|Entre 1,0 y 1,9|Total alumnos con promedio|Alumnos sin promedio|Total alumnos nota deficiente"
    CentrarForma Me
    Me.Show
    Me.Opt_destino(1).Value = True
    Me.Opt_profeasig(1).Value = True
    Me.Btn_Gen_Reporte.Enabled = False
ElseIf Menuinformes3 = "rendimientocurso" Then
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Call Form_main.hideframeimpresion3
    Me.Height = 7870
    Me.Width = 11180
    Me.Frame_Rendcurso.Top = 120
    Me.Frame_Rendcurso.Left = 129
    Me.Frame_Rendcurso.Visible = True
    Call LlenaCombo(cmb_mod_rendcurso, "codigos_ensenanza", "des_ens", "order by ord_ens", conn)
    Call LlenaCombo(cmb_per_rendcurso, "periodos", "des_per", "", conn)
    Call LlenaCombo(Combo1, "alu_x_cur", "Distinct agno", "", conn)
    Combo1.Text = Anno
    If Me.cmb_per_rendcurso.ListCount > 0 Then
        Me.cmb_per_rendcurso.AddItem "ANUAL"
    End If
    Call Grillainicial2
    CentrarForma Me
    Me.Show
    Me.chk_todos_niveles_rendcurso.Enabled = False
    Me.Opt_destino_rendcurso(0).Value = True
    Me.Btn_gen_Rep_Rendcurso.Enabled = False
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call menuhabilitado(True)
End Sub


Private Sub lst_niveles_rendcurso_Click()
Me.cmb_per_rendcurso.Text = ""
Me.Btn_gen_Rep_Rendcurso.Enabled = False
End Sub

Private Sub lst_nom_asi_prof_DblClick()
Profesor = Me.txt_nom_asi_prof.Text
Indi = 0
Busqueda = 0
RutProfe = aprofesores(lst_nom_asi_prof.ListIndex)
rs.CursorLocation = adUseClient
a = "SELECT * FROM profesores where rut_prof = " & "'" & RutProfe & "'"
rs.Open a, conn
If rs.RecordCount > 0 Then
    apellido_p = rs("ape1_prof")
    apellido_m = rs("ape2_prof")
    nombres = rs("noms_prof")
    rs.Close
    Me.txt_nom_asi_prof.Text = apellido_p + " " + apellido_m + " " + nombres
    'Me.txt_rut_asi_prof.Text = separarut(rutprof)
    'Me.txt_dig_asi_prof.Text = separadigito(rutprof)
    Me.lst_nom_asi_prof.Visible = False
    Me.txt_nom_asi_prof.Locked = True
    'Me.txt_rut_asi_prof.Enabled = False
    'Me.txt_dig_asi_prof.Enabled = False
    'Me.cmb_mod_asi_prof.Enabled = True
    'Me.cmb_mod_asi_prof.SetFocus
    SendKeys "{home}"
End If
Me.cmb_asig_impart.Clear
' esta consulta trae codigo asignatura, sector
RsAux.CursorLocation = adUseClient
RsAux.Open "select distinct cod_asi, cod_sec from  asi_x_cur_prof  where rut_prof ='" & RutProfe & "' and agno = " & cb_agno.Text & " order by cod_ens, num_gra asc", conn
c = 0
If RsAux.RecordCount > 0 Then
    ReDim Subsectoresi(RsAux.RecordCount, 2)
    While Not RsAux.EOF ' aqui lleno un array con los subsectores
        Subsectoresi(c, 1) = RsAux("cod_sec"): Subsectoresi(c, 2) = RsAux("cod_asi")
        Me.cmb_asig_impart.AddItem DevuelveCampo("subsectores", "", "nom_asi", "cod_sec = '" & RsAux("cod_sec") & "' and cod_asi = '" & RsAux("cod_asi") & "'", conn)
        RsAux.MoveNext
        c = c + 1
    Wend
End If
RsAux.Close
End Sub

Private Sub Opt_destino_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToPrinter
ElseIf Index = 1 Then
    Form_main.CrystalReport.Destination = crptToWindow
End If
End Sub

Private Sub Opt_destino_rendcurso_Click(Index As Integer)
If Index = 0 Then
    Form_main.CrystalReport.Destination = crptToWindow
ElseIf Index = 1 Then
    Form_main.CrystalReport.Destination = crptToPrinter
End If
End Sub

Private Sub Opt_profeasig_Click(Index As Integer)
' clear los combos y textbox
Me.Btn_Gen_Reporte.Enabled = False
Me.cmb_asig_exist.Clear
Me.cmb_profes_asig.Clear
Me.cmb_asig_impart.Clear
Me.cmb_Periodo_Prof.Clear
Me.cmb_Periodo_subsec.Clear
Me.txt_nom_asi_prof.Text = ""
Call Grillainicial
'Me.Grd_rendimiento.Cols = 2: Me.Grd_rendimiento.Rows = 2
'Me.Grd_rendimiento.Clear
'Me.Grd_rendimiento.FormatString = "               ;Tipo de enseñanza|Cursos que atiende|Matrícula|Promedio del Curso|Promedio más alto|Promedio más bajo|Distribución alumnos por rango|Entre 6,0 y 7,0|Entre 5,0 y 5,9|Entre 4,0 y 4,9|Entre 3,0 y 3,9|Entre 2,0 y 2,9|Entre 1,0 y 1,9|Total alumnos con promedio|Alumnos sin promedio|Total alumnos nota deficiente"
If Index = 0 Then 'Seleccionó por Profesor
    Busqueda = 1
    Me.Frame_profeasig(1).Visible = False
    Me.Frame_profeasig(0).Visible = True
    Me.txt_nom_asi_prof.SetFocus
    Me.txt_nom_asi_prof.Locked = False
    'Call llenacombo(cmb_Periodo_Prof, "Periodos", "des_per", "order by num_per")
    
ElseIf Index = 1 Then 'Seleccionó por subsector
    Me.Frame_profeasig(0).Visible = False
    Me.Frame_profeasig(1).Visible = True
    Me.cmb_asig_exist.SetFocus
    ' esta consulta trae codigo asignatura, sector
    RsAux.CursorLocation = adUseClient
    RsAux.Open "select distinct cod_asi, cod_sec from  subsectores order by cod_sec, cod_asi asc", conn
    c = 0
    If RsAux.RecordCount > 0 Then
        ReDim Subsectoresi(RsAux.RecordCount, 2)
        While Not RsAux.EOF ' aqui lleno un array con los subsectores
            Subsectoresi(c, 1) = RsAux("cod_sec"): Subsectoresi(c, 2) = RsAux("cod_asi")
            Me.cmb_asig_exist.AddItem DevuelveCampo("subsectores", "", "nom_asi", "cod_sec = '" & RsAux("cod_sec") & "' and cod_asi = '" & RsAux("cod_asi") & "'", conn)
            RsAux.MoveNext
            c = c + 1
        Wend
    End If
    RsAux.Close
    
End If
End Sub

Private Sub txt_nom_asi_prof_Change()
If Busqueda = 1 Then
rs.CursorLocation = adUseClient
'fetch the initial table ..
'rs.Open "SELECT * FROM tipo_apo", conn
lst_nom_asi_prof.Clear
If Not ((Chr(KeyAscii) >= "A" And Chr(KeyAscii) <= "Z") Or (Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z")) Then
    KeyAscii = 0
    If Me.txt_nom_asi_prof.Text <> "" Then
      Criterio = "'" + Me.txt_nom_asi_prof.Text + Consulta + "%'"
      rs.Open "SELECT * FROM profesores where ape1_prof like " & Criterio & " order by ape1_prof, ape2_prof, noms_prof", conn
      'rs.FindFirst "des_pre like " + Criterio
            'rs.MoveFirst
        lst_nom_asi_prof.Visible = False
        'Me.Txt_cod_TipoApo.Text = ""
        If rs.RecordCount > 0 Then
            ReDim aprofesores(rs.RecordCount)
            Indi = 0
            X = 0
            While Not rs.EOF
                'Me.Txt_cod_TipoApo.Text = rs(0)
                lst_nom_asi_prof.AddItem rs("ape1_prof") + " " + rs("ape2_prof") + " " + rs("noms_prof")
                aprofesores(X) = rs("rut_prof")
                lst_nom_asi_prof.Visible = True
                rs.MoveNext
                X = X + 1
            Wend
        Else
            Indi = 0
        End If
        rs.Close
    Else
    lst_nom_asi_prof.Visible = False
    End If
End If
End If

End Sub

Private Sub llena_combo_agno()
    Dim i As Integer
    For i = 2004 To Year(Date)
        cb_agno.AddItem i
    Next i
    cb_agno.Text = Year(Date)
End Sub
