VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form_Comprom_Docu 
   Caption         =   "Compromiso Docente"
   ClientHeight    =   6975
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10965
   Icon            =   "Form_Comprom_Docu.frx":0000
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6975
   ScaleWidth      =   10965
   Begin VB.Frame Frame_Rendimientoprofes 
      Height          =   6735
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   10695
      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            =   6360
         TabIndex        =   5
         Top             =   480
         Width           =   1095
      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            =   7800
         TabIndex        =   6
         Top             =   480
         Width           =   1095
      End
      Begin VB.Frame Frame_profeasig 
         Height          =   1815
         Index           =   0
         Left            =   120
         TabIndex        =   13
         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          =   1110
            Left            =   1920
            TabIndex        =   2
            Top             =   600
            Visible         =   0   'False
            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        =   4
            Top             =   1320
            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        =   3
            Top             =   840
            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        =   1
            Top             =   360
            Width           =   3735
         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        =   16
            Top             =   360
            Width           =   1575
         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        =   15
            Top             =   840
            Width           =   1935
         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        =   14
            Top             =   1320
            Width           =   855
         End
      End
      Begin VB.Frame Frame5 
         Caption         =   "Rendimiento del profesor Año Anterior"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   4575
         Left            =   120
         TabIndex        =   10
         Top             =   2040
         Width           =   10455
         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            =   2640
            TabIndex        =   11
            TabStop         =   0   'False
            Top             =   600
            Visible         =   0   'False
            Width           =   1215
         End
         Begin MSFlexGridLib.MSFlexGrid Grd_rendimiento 
            Height          =   4215
            Left            =   120
            TabIndex        =   12
            TabStop         =   0   'False
            Top             =   240
            Width           =   10215
            _ExtentX        =   18018
            _ExtentY        =   7435
            _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.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        =   9
         Top             =   1560
         Width           =   1575
      End
      Begin VB.CommandButton btn_gen_reporte 
         Caption         =   "Imprimir Compromiso"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   9000
         TabIndex        =   8
         Top             =   840
         Width           =   1575
      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        =   7
         Top             =   360
         Width           =   1575
      End
   End
End
Attribute VB_Name = "Form_Comprom_Docu"
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 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_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", ConnAnt)
    '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 & "'", ConnAnt)
        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 <= '" & FechaFinPer & "'", ConnAnt: 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 <= '" & FechaFinPer & "' 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 <= '" & FechaFinPer & "' 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", ConnAnt: 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 <= '" & FechaFinPer & "' 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", ConnAnt: 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 <= '" & FechaFinPer & "' 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", ConnAnt: 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(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: Rango1 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(7, t) = Rango1: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: Rango2 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(8, t) = Rango2: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: Rango3 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(9, t) = Rango3: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: Rango4 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(10, t) = Rango4: Abarra = Abarra + 1
    
    rs.CursorLocation = adUseClient: rs.Open "select count(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: Rango5 = rs(0): rs.Close
    Me.Grd_rendimiento.TextMatrix(11, t) = Rango5: Abarra = Abarra + 1

    rs.CursorLocation = adUseClient: rs.Open "select count(" & 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 <= '" & FechaFinPer & "' 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", ConnAnt: 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_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
    'horiz = Left(horiz, Len(horiz) - 2): horiz = "(" & horiz & ")"
'    a = "insert into Detalles " & ins & " values " & detal
'    Rendim.Execute a
    'b = "insert into Detalles " & ins & " values " & horiz
    'If R >= 1 Then
    '    Rendim.Execute b
    'End If
Next R
Rendim.Close
    Titulo = "COMPROMISO DOCENTE "
    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\Comprom_Doc.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()
Me.Btn_Gen_Reporte.Enabled = False
Me.cmb_asig_impart.Clear
Me.cmb_Periodo_Prof.Clear
Me.txt_nom_asi_prof.Text = ""
Call Grillainicial
Busqueda = 1
Me.Frame_profeasig(0).Visible = True
Me.txt_nom_asi_prof.SetFocus
Me.txt_nom_asi_prof.Locked = False
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", ConnAnt)
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
' Año Anterior
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", ConnAnt
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
End If
rs.Close
End Sub

Private Sub cmb_asig_impart_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 Form_Load()
    Set rs = New ADODB.Recordset
    Set RsAux = New ADODB.Recordset
    Me.Height = 7395
    Me.Width = 11040
    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.Btn_Gen_Reporte.Enabled = False
    Busqueda = 1
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call ModificarDsn("GesCol", Servidor, "gescol", "consultor", "")
Call menuhabilitado(True)
End Sub

Private Sub lst_nom_asi_prof_DblClick()
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
Servidor = IniGet("GESCOL.INI", "Servidor", "IP", "")
If Len(Trim(Servidor)) = 0 Then
    Servidor = InputBox("Ingrese IP del Servidor", "IP Servidor")
    IniWrite "GESCOL.INI", "Servidor", "IP", Servidor
    IniWrite "GESCOL.INI", "Servidor", "Base de Datos", "Gescol"
End If
Base = IniGet("GESCOL.INI", "Servidor", "Base de Datos", "") & Val(Anno) - 1
If ConectarBD(ConnAnt, Servidor, Base, "groot", PassBDLocal, False) Then
    'Esta consulta trae codigo asignatura, sector del año anterior
    RsAux.CursorLocation = adUseClient
    RsAux.Open "select distinct  cod_asi, cod_sec from  asi_x_cur_prof  where rut_prof ='" & RutProfe & "'  order by cod_ens, num_gra asc", ConnAnt
    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
    Profesor = Me.txt_nom_asi_prof.Text
Else
    MsgBox "No fue posible establecer conexión con la base de datos " & Base & Chr(13) & " del año escolar anterior"
    Exit Sub
End If
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 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
