VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#4.6#0"; "crystl32.ocx"
Begin VB.Form Form_Profesores_Por_Curso 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta de Cursos"
   ClientHeight    =   7155
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11115
   Icon            =   "Form_Profesores_Por_Curso.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7155
   ScaleWidth      =   11115
   Begin TabDlg.SSTab SSTab1 
      Height          =   5535
      Left            =   120
      TabIndex        =   12
      Top             =   1440
      Width           =   10815
      _ExtentX        =   19076
      _ExtentY        =   9763
      _Version        =   393216
      Tabs            =   2
      Tab             =   1
      TabHeight       =   520
      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
      TabCaption(0)   =   "Profesores por Curso"
      TabPicture(0)   =   "Form_Profesores_Por_Curso.frx":2A8B2
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "frame_profesores"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Frame3"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).ControlCount=   2
      TabCaption(1)   =   "Alumnos por Curso"
      TabPicture(1)   =   "Form_Profesores_Por_Curso.frx":2A8CE
      Tab(1).ControlEnabled=   -1  'True
      Tab(1).Control(0)=   "jornada"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).Control(1)=   "profe_jefe"
      Tab(1).Control(1).Enabled=   0   'False
      Tab(1).Control(2)=   "curso"
      Tab(1).Control(2).Enabled=   0   'False
      Tab(1).Control(3)=   "Frame2"
      Tab(1).Control(3).Enabled=   0   'False
      Tab(1).Control(4)=   "Frame4"
      Tab(1).Control(4).Enabled=   0   'False
      Tab(1).Control(5)=   "Frame5"
      Tab(1).Control(5).Enabled=   0   'False
      Tab(1).ControlCount=   6
      Begin VB.Frame Frame5 
         Caption         =   "Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   3720
         TabIndex        =   25
         Top             =   480
         Width           =   3375
         Begin VB.OptionButton opt_impresora2 
            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
            Left            =   240
            TabIndex        =   28
            Top             =   480
            Width           =   1215
         End
         Begin VB.OptionButton opt_pantalla2 
            Caption         =   "Por Pantalla"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   240
            TabIndex        =   27
            Top             =   240
            Value           =   -1  'True
            Width           =   1335
         End
         Begin VB.CommandButton Command1 
            Caption         =   "Generar Reporte"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1800
            TabIndex        =   26
            Top             =   360
            Width           =   1455
         End
      End
      Begin VB.Frame Frame4 
         Caption         =   "Ver"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   120
         TabIndex        =   21
         Top             =   480
         Width           =   3255
         Begin VB.CommandButton cmd_ver_alumnos 
            Caption         =   "Ver"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1920
            TabIndex        =   24
            Top             =   360
            Width           =   1215
         End
         Begin VB.OptionButton Option1 
            Caption         =   "Todos"
            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        =   23
            Top             =   480
            Width           =   1095
         End
         Begin VB.OptionButton Option1 
            Caption         =   "Alumnos activos"
            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        =   22
            Top             =   240
            Value           =   -1  'True
            Width           =   1575
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Frame2"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   3975
         Left            =   120
         TabIndex        =   19
         Top             =   1440
         Width           =   10575
         Begin MSHierarchicalFlexGridLib.MSHFlexGrid grid_alumnos 
            Height          =   3495
            Left            =   120
            TabIndex        =   20
            Top             =   360
            Width           =   10095
            _ExtentX        =   17806
            _ExtentY        =   6165
            _Version        =   393216
            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
            _NumberOfBands  =   1
            _Band(0).Cols   =   2
         End
      End
      Begin VB.Frame Frame3 
         Caption         =   "Reporte"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   855
         Left            =   -74880
         TabIndex        =   15
         Top             =   480
         Width           =   3375
         Begin VB.CommandButton cmd_reporte 
            Caption         =   "Generar Reporte"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1800
            TabIndex        =   18
            Top             =   360
            Width           =   1455
         End
         Begin VB.OptionButton opt_pantalla 
            Caption         =   "Por Pantalla"
            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        =   17
            Top             =   240
            Value           =   -1  'True
            Width           =   1335
         End
         Begin VB.OptionButton opt_impresora 
            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
            Left            =   120
            TabIndex        =   16
            Top             =   480
            Width           =   1215
         End
      End
      Begin VB.Frame frame_profesores 
         Caption         =   "Frame3"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   3975
         Left            =   -74880
         TabIndex        =   13
         Top             =   1440
         Width           =   10575
         Begin MSHierarchicalFlexGridLib.MSHFlexGrid grid 
            Height          =   3375
            Left            =   120
            TabIndex        =   14
            Top             =   360
            Width           =   10335
            _ExtentX        =   18230
            _ExtentY        =   5953
            _Version        =   393216
            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
            _NumberOfBands  =   1
            _Band(0).Cols   =   2
         End
      End
      Begin VB.Label curso 
         Caption         =   "Label4"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   8760
         TabIndex        =   31
         Top             =   720
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Label profe_jefe 
         Caption         =   "Label5"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   7320
         TabIndex        =   30
         Top             =   1080
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Label jornada 
         Caption         =   "Label4"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   7320
         TabIndex        =   29
         Top             =   720
         Visible         =   0   'False
         Width           =   1095
      End
   End
   Begin VB.CommandButton Command3 
      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            =   9600
      TabIndex        =   11
      Top             =   480
      Width           =   1215
   End
   Begin VB.CommandButton cmd_limpiar 
      Caption         =   "Otro Curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7560
      TabIndex        =   10
      Top             =   720
      Width           =   1215
   End
   Begin VB.CommandButton Btn_Ver_Curso 
      Caption         =   "Ver"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7560
      TabIndex        =   9
      Top             =   240
      Width           =   1215
   End
   Begin Crystal.CrystalReport cr_prof_x_curso 
      Left            =   240
      Top             =   8280
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   262150
   End
   Begin VB.Frame Frame1 
      Caption         =   "Seleccione Curso"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   7215
      Begin VB.CheckBox Check_Letra 
         Caption         =   "Letra"
         ForeColor       =   &H00000000&
         Height          =   195
         Left            =   5880
         TabIndex        =   1
         Top             =   240
         Value           =   1  'Checked
         Visible         =   0   'False
         Width           =   1095
      End
      Begin MSComctlLib.ImageCombo IC_Ensenanza 
         Height          =   345
         Left            =   1440
         TabIndex        =   2
         Top             =   480
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Ensenanza"
      End
      Begin MSComctlLib.ImageCombo IC_Nivel 
         Height          =   345
         Left            =   4680
         TabIndex        =   3
         Top             =   480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Nivel"
      End
      Begin MSComctlLib.ImageCombo IC_Letra 
         Height          =   345
         Left            =   5880
         TabIndex        =   4
         Top             =   480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Letra"
      End
      Begin MSComctlLib.ImageCombo IC_Agno 
         Height          =   345
         Left            =   240
         TabIndex        =   5
         Top             =   480
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         _Version        =   393216
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         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
         Locked          =   -1  'True
         Text            =   "IC_Agno"
      End
      Begin VB.Label Label3 
         Alignment       =   2  'Center
         Caption         =   "Nivel"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   4560
         TabIndex        =   8
         Top             =   240
         Width           =   615
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "Enseñanza"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   1440
         TabIndex        =   7
         Top             =   240
         Width           =   975
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         Caption         =   "Año"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   240
         Width           =   495
      End
   End
End
Attribute VB_Name = "Form_Profesores_Por_Curso"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Rec2Grid(ByRef REC As ADODB.Recordset, ByRef grid As Object, Optional ByVal Numeracion As Boolean = True)
    grid.ClearStructure
    If REC.RecordCount > 0 Then
        grid.Cols = REC.Fields.count + 1
        grid.Rows = REC.RecordCount + 1
        grid.FixedCols = 1
        grid.FixedRows = 1
        grid.TextMatrix(0, 0) = "Nº"
        grid.ColWidth(0) = IIf(Numeracion, TextWidth(grid.TextMatrix(0, 0)) + 100, 0)
        For i = 1 To REC.Fields.count
            grid.TextMatrix(0, i) = UCase(REC.Fields(i - 1).Name)
            grid.ColWidth(i) = TextWidth(grid.TextMatrix(0, i)) + 100
        Next i
        REC.MoveFirst
        For i = 1 To REC.RecordCount
            'progreso.Value = i
            grid.TextMatrix(i, 0) = i
            grid.ColWidth(0) = IIf(Numeracion, IIf(TextWidth(grid.TextMatrix(i, 0)) + 100 > grid.ColWidth(0), TextWidth(grid.TextMatrix(i, 0)) + 100, grid.ColWidth(0)), 0)
            For j = 1 To REC.Fields.count
                grid.TextMatrix(i, j) = IIf(IsNull(REC(j - 1)), "Null", REC(j - 1))
                grid.ColWidth(j) = IIf(TextWidth(grid.TextMatrix(i, j)) + 100 > grid.ColWidth(j), TextWidth(grid.TextMatrix(i, j)) + 100, grid.ColWidth(j))
            Next j
            REC.MoveNext
        Next i
    Else
        grid.Cols = 2
        grid.Rows = 2
    End If
End Sub

Private Sub Btn_Ver_Curso_Click()
    Dim bd As String
    SSTab1.Tab = 0
    bd = App.Path & "\Rpt\pro_x_cur.mdb"
    'tabla = "reporte"
    CreaBD (bd)
    Call CreaTablaReporte(bd, "reporte")
    Call CreaTablaReporte_alumnos(bd, "alumnos")
    llena_grilla
    llena_alumnos
    Frame1.Enabled = False
End Sub

Private Sub cmd_limpiar_Click()
    limpiar
End Sub

Private Sub cmd_reporte_Click()
    If grid.TextMatrix(1, 1) <> "" Then
        Dim objRS As ADODB.Recordset
        Set objRS = New ADODB.Recordset
        Dim est, dir As String
        Dim var_sql As String
        var_sql = "SELECT nom_est,dir_est FROM establecimientos"
        objRS.Open var_sql, conn
        If Not objRS.EOF Then
            est = objRS("nom_est")
            dir = objRS("dir_est")
        End If
        objRS.Close
        cr_prof_x_curso.ReportFileName = App.Path & "\Rpt\profesores_x_curso.rpt"
        Call LimpiaFormulas(cr_prof_x_curso, 30)
        cr_prof_x_curso.Formulas(1) = "nom_est = '" & est & "'"
        cr_prof_x_curso.Formulas(2) = "dir_est = '" & dir & "'"
        cr_prof_x_curso.Formulas(3) = "agno = '" & IC_Agno.Text & "'"
        cr_prof_x_curso.DataFiles(0) = App.Path & "\Rpt\pro_x_cur.mdb"
        If opt_pantalla.Value = True Then
            cr_prof_x_curso.Destination = crptToWindow
        Else
            cr_prof_x_curso.Destination = crptToPrinter
        End If
        cr_prof_x_curso.Action = 1
    Else
        MsgBox "No hay datos seleccionados para la generación del reporte", vbInformation
    End If
End Sub

Private Sub cmd_ver_alumnos_Click()
    llena_alumnos
End Sub

Private Sub Command1_Click()
    If grid_alumnos.TextMatrix(1, 1) <> "" Then
        Dim objRS As ADODB.Recordset
        Set objRS = New ADODB.Recordset
        Dim est, dir As String
        Dim var_sql As String
        var_sql = "SELECT nom_est,dir_est FROM establecimientos"
        objRS.Open var_sql, conn
        If Not objRS.EOF Then
            est = objRS("nom_est")
            dir = objRS("dir_est")
        End If
        objRS.Close
        If Option1(0).Value = True Then
            cr_prof_x_curso.ReportFileName = App.Path & "\Rpt\lista_curso.rpt"
        Else
            cr_prof_x_curso.ReportFileName = App.Path & "\Rpt\lista_curso_todos.rpt"
        End If
        Call LimpiaFormulas(cr_prof_x_curso, 30)
        cr_prof_x_curso.Formulas(1) = "nom_est = '" & est & "'"
        cr_prof_x_curso.Formulas(2) = "dir_est = '" & dir & "'"
        cr_prof_x_curso.Formulas(3) = "agno = '" & IC_Agno.Text & "'"
        cr_prof_x_curso.Formulas(4) = "curso = '" & curso.Caption & "'"
        cr_prof_x_curso.Formulas(5) = "jornada = '" & jornada.Caption & "'"
        cr_prof_x_curso.Formulas(6) = "profe_jefe = '" & profe_jefe.Caption & "'"
        cr_prof_x_curso.Formulas(7) = "total_alumnos = '" & (grid_alumnos.Rows - 1) & "'"
        cr_prof_x_curso.DataFiles(0) = App.Path & "\Rpt\pro_x_cur.mdb"
        If opt_pantalla2.Value = True Then
            cr_prof_x_curso.Destination = crptToWindow
        Else
            cr_prof_x_curso.Destination = crptToPrinter
        End If
        cr_prof_x_curso.Action = 1
    Else
        MsgBox "No hay datos seleccionados para la generación del reporte", vbInformation
    End If
End Sub

Private Sub Command3_Click()
Unload Me
End Sub



Private Sub Form_Load()
' Setear el combo años.
    Me.Top = 0
    Me.Left = 0
    IC_Letra.Text = ""
    IC_Letra.ComboItems.Clear
    Call Set_IC_Agno
    ' Limpiar textos
    'txt_nom_alu.Text = ""
    'txt_rut_alu.Text = ""
    'txt_nom_apo.Text = ""
    'txt_rut_apo.Text = ""
    'Mostrar opcion de curso al iniciar
    'Option1(0).Value = True
    'MuestraFrame ("curso")
    ErrorStatus = False
End Sub

Private Sub IC_Agno_Click()
    IC_Ensenanza.Enabled = True
    Set_IC_Ensenanza
End Sub

Private Sub lst_nom_alu_Click()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    txt_nom_alu.Text = lst_nom_alu.Text
    lst_nom_alu.Visible = False
    lst_rut_alu.Visible = False
    RC.Open "SELECT ci_alu FROM postulantes WHERE left(CONCAT(ape_Pat_alu,' ',ape_Mat_alu,' ',nom_alu)," & Len(txt_nom_alu.Text) & ")='" & txt_nom_alu.Text & "' ORDER BY ape_pat_alu, ape_mat_alu, nom_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_rut_alu.Text = RC("ci_alu")
    RC.Close
    Flag_sub = False
    Btn_Ver_Alumno.Enabled = True
End Sub

Private Sub lst_rut_alu_Click()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    txt_rut_alu.Text = lst_rut_alu.Text
    lst_rut_alu.Visible = False
    lst_nom_alu.Visible = False
    RC.Open "SELECT CONCAT(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu) as nombre_alu FROM postulantes WHERE ci_alu='" & txt_rut_alu.Text & "' ORDER BY ci_alu;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_nom_alu.Text = RC("nombre_alu")
    RC.Close
    Flag_sub = False
    Btn_Ver_Alumno.Enabled = True
End Sub

Private Sub lst_nom_apo_Click()
    Dim RC As ADODB.Recordset
    txt_nom_apo.Text = lst_nom_apo.Text
    lst_nom_apo.Visible = False
    lst_rut_apo.Visible = False
    Set RC = New ADODB.Recordset
    RC.Open "SELECT rut_apo FROM `apoderados` where left(CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo)," & Len(txt_nom_apo.Text) & ")='" & txt_nom_apo.Text & "' ORDER BY ape1_apo, ape2_apo, noms_apo;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_rut_apo.Text = RC("rut_apo")
    Flag_sub = False
    Btn_Ver_Apoderado.Enabled = True
    RC.Close
End Sub

Private Sub lst_rut_apo_Click()
    Dim RC As ADODB.Recordset
    txt_rut_apo.Text = lst_rut_apo.Text
    lst_rut_apo.Visible = False
    lst_nom_apo.Visible = False
    Set RC = New ADODB.Recordset
    RC.Open "SELECT CONCAT(ape1_apo,' ',ape2_apo,' ',noms_apo) as nombre_apo FROM apoderados where rut_apo='" & txt_rut_apo.Text & "' ORDER BY rut_apo;", conn
    RC.MoveFirst
    Flag_sub = True
    txt_nom_apo.Text = RC("nombre_apo")
    Flag_sub = False
    Btn_Ver_Apoderado.Enabled = True
    RC.Close
End Sub

'Private Sub Option1_Click(Index As Integer)
'    txt_nom_alu.Text = ""
'    txt_rut_alu.Text = ""
'    txt_nom_apo.Text = ""
'    txt_rut_apo.Text = ""
'    lst_nom_alu.Visible = False
'    lst_rut_alu.Visible = False
'    lst_nom_apo.Visible = False
'    lst_rut_apo.Visible = False
'    If Option1(Index).Value = True Then
'        If Index = 0 Then
'            MuestraFrame "curso"
'        ElseIf Index = 1 Then
'            MuestraFrame "apoderado"
'        ElseIf Index = 2 Then
'            MuestraFrame "alumno"
'        End If
'    End If
'End Sub

Private Sub Set_IC_Ensenanza()
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    QRY = "SELECT DISTINCT m.cod_ens, ce.des_ens FROM matriculas as m, codigos_ensenanza as ce WHERE m.cod_ens=ce.cod_ens AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY ce.ord_ens;"
    Set REC = New ADODB.Recordset
    REC.Open QRY, conn
    
    IC_Ensenanza.ComboItems.Clear
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        For i = 1 To REC.RecordCount
            IC_Ensenanza.ComboItems.Add i, "K" & Format(REC!Cod_Ens, "000"), REC!des_ens
            REC.MoveNext
        Next i
        Set IC_Ensenanza.SelectedItem = IC_Ensenanza.ComboItems.Item(1)
        ErrorStatus = False
        ' Llenar Siguiente Combo.
        IC_Nivel.Enabled = True
        IC_Letra.Enabled = False
        Call Set_IC_Nivel
    Else
        ErrorStatus = True
        IC_Ensenanza.Enabled = False
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    REC.Close
End Sub



Private Sub IC_Ensenanza_Click()
    IC_Nivel.Enabled = True
    Call Set_IC_Nivel
End Sub

Private Sub Set_IC_Nivel()
    Dim REC As ADODB.Recordset
    Dim QRY As String

    QRY = "SELECT DISTINCT m.num_gra FROM matriculas as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.anno_mat=" & IC_Agno.SelectedItem.Text & " ORDER BY m.num_gra;"
    Set REC = New ADODB.Recordset
    REC.Open QRY, conn
    
    IC_Nivel.ComboItems.Clear
    If REC.RecordCount > 0 Then
        REC.MoveFirst
        For i = 1 To REC.RecordCount
            IC_Nivel.ComboItems.Add i, , str(REC!Num_Gra)
            REC.MoveNext
        Next i
        Set IC_Nivel.SelectedItem = IC_Nivel.ComboItems.Item(1)
        ErrorStatus = False
        ' Llenar Siguiente Combo.
        If Check_Letra.Value = 1 Then
            IC_Letra.Enabled = True
            Call Set_IC_Letra
        End If
    Else
        ErrorStatus = True
        IC_Nivel.Enabled = False
        IC_Letra.Enabled = False
    End If
    REC.Close
End Sub






Private Sub IC_Nivel_Click()
  '  If Check_Letra.Value = 1 Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
   ' End If
End Sub

Private Sub Set_IC_Letra()
    Dim REC As ADODB.Recordset
    Dim QRY As String
    
    'If Check_Letra.Value = 1 Then
        IC_Letra.ComboItems.Clear
        IC_Letra.Text = ""
        QRY = "SELECT DISTINCT m.let_cur FROM alu_x_cur as m WHERE m.cod_ens='" & Mid(IC_Ensenanza.SelectedItem.Key, 2) & "' AND m.agno=" & Trim(IC_Agno.SelectedItem.Text) & " AND m.num_gra='" & Trim(IC_Nivel.SelectedItem.Text) & "' ORDER BY m.num_gra;"
        Set REC = New ADODB.Recordset
        REC.Open QRY, conn
        If REC.RecordCount > 0 Then
            REC.MoveFirst
            For i = 1 To REC.RecordCount
                IC_Letra.ComboItems.Add i, , REC!Let_Cur
                REC.MoveNext
            Next i
            Set IC_Letra.SelectedItem = IC_Letra.ComboItems.Item(1)
            ErrorStatus = False
            ' Llenar Siguiente Combo.
        Else
            ErrorStatus = True
            Check_Letra.Value = 0
            IC_Letra.Enabled = False
        End If
        REC.Close
'    Else
'        ErrorStatus = False
'        IC_Letra.Enabled = False
'    End If
End Sub

Private Sub Check_Letra_Click()
    If Check_Letra.Value = 0 Then
        IC_Letra.Enabled = False
    ElseIf Check_Letra.Value = 1 And Not (ErrorStatus) And IC_Ensenanza.Enabled And IC_Nivel.Enabled Then
        IC_Letra.Enabled = True
        Call Set_IC_Letra
    Else
        Check_Letra.Value = 0
        IC_Letra.Enabled = False
    End If
End Sub

'Private Sub MuestraFrame(ByVal frm As String)
'    ' Muestra seleccion por curso
'    If frm = "curso" Then
'        Frame1.Visible = True
'        'SeteaVistaCurso
'    Else
'        Frame1.Visible = False
'    End If
'    ' Muestra seleccion por apoderado
'    If frm = "apoderado" Then
'        Frame5.Visible = True
'        'SeteaVistaApoderado
'        Btn_Ver_Alumno.Enabled = False
'    Else
'        Frame5.Visible = False
'    End If
'    ' Muestra seleccion por alumno
'    If frm = "alumno" Then
'        Frame4.Visible = True
'        Btn_Ver_Apoderado.Enabled = False
'        'SeteaVistaAlumno
'    Else
'        Frame4.Visible = False
'    End If
'End Sub

Private Sub Set_IC_Agno()
    Dim agno As Integer
    
  '  agno = IIf(Year(Date) < 2005, 2005, Year(Date))
  '  IC_Agno.ComboItems.Clear
'    For i = 2005 To (Anno)
'        IC_Agno.ComboItems.Add i, , str(i + 2004)
'    Next i
'    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(i - 1)
'    ErrorStatus = False
    
    agno = IIf(Year(Date) < 2005, 2005, Year(Date))
    IC_Agno.ComboItems.Clear
    For i = 1 To (agno - 2004)
        IC_Agno.ComboItems.Add i, , str(i + 2004)
    Next i
    Set IC_Agno.SelectedItem = IC_Agno.ComboItems.Item(i - 1)
    ErrorStatus = False
    
    ' Llenar combo enseñanza
    IC_Ensenanza.Enabled = True
    IC_Nivel.Enabled = False
    IC_Letra.Enabled = False
    Call Set_IC_Ensenanza
End Sub
 
Private Sub txt_nom_alu_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_nom_alu.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    
    RC.Open "SELECT DISTINCT a.ape_pat_alu, a.ape_mat_alu, a.nom_alu FROM postulantes a, matriculas m WHERE left(CONCAT(a.ape_pat_alu,' ',a.ape_mat_alu,' ',a.nom_alu)," & Len(txt_nom_alu.Text) & ")='" & txt_nom_alu.Text & "' AND a.ci_alu=m.ci_alu ORDER BY a.ape_pat_alu, a.ape_mat_alu, a.nom_alu;", conn
    lst_nom_alu.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            lst_nom_alu.AddItem RC("ape_pat_alu") & " " & RC("ape_mat_alu") & " " & RC("nom_alu")
            RC.MoveNext
        Wend
        lst_nom_alu.Visible = True
        lst_rut_alu.Visible = False
    End If
    RC.Close
    Btn_Ver_Alumno.Enabled = False
End Sub

Private Sub txt_rut_alu_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_rut_alu.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
    
    RC.Open "SELECT DISTINCT a.ci_alu FROM postulantes a, matriculas m WHERE left(a.ci_alu," & Len(txt_rut_alu.Text) & ")='" & txt_rut_alu.Text & "' AND a.ci_alu=m.ci_alu ORDER BY a.ci_alu;", conn
    lst_rut_alu.Clear
    If RC.RecordCount > 0 Then
        While Not (RC.EOF)
            lst_rut_alu.AddItem RC("ci_alu")
            RC.MoveNext
        Wend
        lst_nom_alu.Visible = False
        lst_rut_alu.Visible = True
    End If
    RC.Close
    Btn_Ver_Alumno.Enabled = False
End Sub

Private Sub txt_nom_apo_Change()
    Dim RC As ADODB.Recordset
    ' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_nom_apo.Text = "" Then Exit Sub
    Set RC = New ADODB.Recordset
        
    RC.Open "SELECT DISTINCT a.ape1_apo, a.ape2_apo, a.noms_apo FROM apoderados a, fnza_mensualidad fm where left(CONCAT(a.ape1_apo,' ',a.ape2_apo,' ',a.noms_apo)," & Len(txt_nom_apo.Text) & ")='" & txt_nom_apo.Text & "' and a.rut_apo=fm.run_apo ORDER BY a.ape1_apo, a.ape2_apo, a.noms_apo;", conn
    lst_nom_apo.Clear
    While Not (RC.EOF)
        lst_nom_apo.AddItem RC("ape1_apo") & " " & RC("ape2_apo") & " " & RC("noms_apo")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver_Apoderado.Enabled = False
    lst_nom_apo.Visible = True
    lst_rut_apo.Visible = False
End Sub

Private Sub txt_rut_apo_Change()
' Si el cambio lo hace un Sub no hacer nada
    If Flag_sub Then Exit Sub
    If txt_rut_apo.Text = "" Then Exit Sub
    Dim Str_Query As String
    Dim RC As ADODB.Recordset
    
    Set RC = New ADODB.Recordset
    Str_Query = "SELECT DISTINCT fm.run_apo FROM apoderados a, fnza_mensualidad fm WHERE left(a.rut_apo," & Len(txt_rut_apo.Text) & ")='" & txt_rut_apo.Text & "' AND a.rut_apo=fm.run_apo ORDER BY a.rut_apo;"
    RC.Open Str_Query, conn
    lst_rut_apo.Clear
    While Not (RC.EOF)
        lst_rut_apo.AddItem RC("run_apo")
        RC.MoveNext
    Wend
    RC.Close
    Btn_Ver_Apoderado.Enabled = False
    lst_rut_apo.Visible = True
    lst_nom_apo.Visible = False
End Sub


Private Sub llena_grilla()
    Dim bd As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
  
    Dim var_sql As String
    Dim Cod_Ens As String
    
    Select Case IC_Ensenanza.Text
        Case Is = "Educación Parvularia"
            Cod_Ens = "010"
        Case Is = "Educación General Básica"
            Cod_Ens = "110"
        Case Is = "Educación Media H/C niños y jóvenes"
            Cod_Ens = "310"
        Case Is = "Otros Tipos (Pre Kinder)"
            Cod_Ens = "996"
    End Select
'    var_sql = "select pxc.*,concat(p.ape1_prof,' ',p.ape2_prof,' ',p.noms_prof) as 'Profesor Jefe'" _
'            & " from (select nom_sec as 'Nombre Sector'," _
'            & " ss.cod_asi as 'Cod. Asig.'," _
'            & " nom_asi as 'Nombre Asig.',p.rut_prof as 'R.U.T. Prof.'," _
'            & " concat(ape1_prof,' ',ape2_prof,' ',noms_prof) as 'Nombre Profesor'," _
'            & " concat(axc.num_gra,' ',axc.let_cur,' ',cod_des) as 'Curso'," _
'            & " c.rut_prof as 'prof_jefe'" _
'            & " from sectores s,subsectores ss,asi_x_cur_prof axc,cursos c,profesores p," _
'            & " codigos_ensenanza ce" _
'            & " Where s.cod_sec = ss.cod_sec And ss.cod_sec = axc.cod_sec And" _
'            & " ss.cod_asi = axc.cod_asi" _
'            & " and ss.cod_ens = axc.cod_ens and ss.num_gra = axc.num_gra and" _
'            & " axc.cod_ens = c.cod_ens and axc.num_gra = c.num_gra and" _
'            & " axc.let_cur = c.let_cur and" _
'            & " axc.agno = c.agno And axc.rut_prof = p.rut_prof And" _
'            & " axc.Cod_Ens = ce.Cod_Ens And axc.agno = " & IC_Agno.Text _
'            & " and axc.cod_ens = '" & Cod_Ens & "' and axc.num_gra = " & IC_Nivel.Text _
'            & " and axc.let_cur = '" & IC_Letra.Text _
'            & "' order by axc.cod_sec,axc.cod_ens,axc.num_gra,axc.cod_asi)" _
'            & " as pxc,profesores p" _
'            & " where pxc.prof_jefe = p.rut_prof"

    var_sql = "SELECT d.agno,concat(d.num_gra,' ',d.let_cur,' ',cod_des) as curso, pj.rut_prof," _
            & "concat(pj.noms_prof,' ', pj.ape1_prof,' ', pj.ape2_prof) as nom_prof_jefe," _
            & "d.cod_sec as 'Cod. Sec.', d.nom_sec as 'Sector', d.cod_asi as 'Cod. Asig.'," _
            & "d.nom_asi as 'Asignatura', d.prof_asi as 'Rut. Prof.', d.nom_prof as 'Profesor'" _
            & " FROM (SELECT c.*, cod_des,acp.rut_prof as 'prof_asi', acp.cod_sec, acp.cod_asi, s.nom_sec," _
            & "a.nom_asi, concat(p.noms_prof,' ', p.ape1_prof,' ', p.ape2_prof) as nom_prof" _
            & " FROM cursos as c, asi_x_cur_prof as acp, sectores as s, subsectores as a, profesores as p," _
            & "codigos_ensenanza ce WHERE c.cod_ens=acp.cod_ens AND c.num_gra=acp.num_gra AND" _
            & " c.let_cur=acp.let_cur AND c.agno=acp.agno AND acp.cod_sec=s.cod_sec AND" _
            & " acp.cod_sec=a.cod_sec AND acp.cod_asi=a.cod_asi AND acp.cod_ens=a.cod_ens AND" _
            & " acp.num_gra=a.num_gra AND acp.rut_prof=p.rut_prof and acp.cod_ens = ce.cod_ens) as d LEFT JOIN" _
            & " profesores as pj ON d.rut_prof=pj.rut_prof WHERE d.agno = " & IC_Agno.Text _
            & " and d.num_gra = " & IC_Nivel.Text & " and d.let_cur = '" & IC_Letra.Text _
            & "' and d.cod_ens = '" & Cod_Ens _
            & "' ORDER BY d.agno, d.cod_ens, d.num_gra, d.let_cur, d.cod_sec, d.cod_asi"

    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        'progreso.Min = 0
        'progreso.Max = objRS.RecordCount
        Call Rec2Grid(objRS, grid, True)
        grid.ColWidth(1) = 0
        grid.ColWidth(2) = 0
        grid.ColWidth(3) = 0
        grid.ColWidth(4) = 0
        objRS.MoveFirst
        frame_profesores.Caption = "Profesor Jefe: " & objRS("nom_prof_jefe") & "   -   Rut: " & objRS("rut_prof")
        profe_jefe.Caption = objRS("nom_prof_jefe")
        'objRS.Close
        'Frame1.Enabled = False
        bd = App.Path & "\Rpt\pro_x_cur.mdb"
        Call llenar_tabla(bd, "reporte")
    Else
        SSTab1.Tab = 1
'        MsgBox "La busqueda no arrojo resultados", vbInformation
    End If
    objRS.Close
End Sub
Private Sub limpiar()
    frame_profesores.Caption = ""
    grid.ClearStructure
    grid.Rows = 2
    grid_alumnos.ClearStructure
    grid_alumnos.Rows = 2
    Frame1.Enabled = True
End Sub

Private Sub llenar_tabla(bd As String, tabla As String)
Dim dbsTemp As Database
Set dbsTemp = OpenDatabase(bd)
Dim var_sql As String
For i = 1 To grid.Rows - 1
    var_sql = "insert into reporte(correlativo,agno,curso,rut_prof_jefe,nom_prof_jefe,cod_sec,nom_sec,cod_asig,nom_asig,rut_prof,nom_prof)" _
            & " values(" & grid.TextMatrix(i, 0) & "," & grid.TextMatrix(i, 1) & ",'" _
            & grid.TextMatrix(i, 2) & "','" & grid.TextMatrix(i, 3) & "','" & grid.TextMatrix(i, 4) & "','" _
            & grid.TextMatrix(i, 5) & "','" & grid.TextMatrix(i, 6) & "','" _
            & grid.TextMatrix(i, 7) & "','" & grid.TextMatrix(i, 8) & "','" _
            & grid.TextMatrix(i, 9) & "','" & grid.TextMatrix(i, 10) & "')"
    dbsTemp.Execute var_sql
Next i
curso.Caption = grid.TextMatrix(1, 2)
End Sub

Private Sub CreaTablaReporte(NomBd As String, NomTabla As String)
'On Error GoTo errores
Dim dbsTemp As Database
Dim NumCampos, TipoCampo As Integer
Dim tdfNuevo As TableDef
Set dbsTemp = OpenDatabase(NomBd)
Set tdfNuevo = dbsTemp.CreateTableDef(NomTabla)

    With tdfNuevo
        .Fields.Append .CreateField("correlativo", adInteger)
        .Fields.Append .CreateField("agno", adInteger)
        .Fields.Append .CreateField("cod_sec", dbText, 4)
        .Fields.Append .CreateField("nom_sec", dbText, 35)        ' Una cadena de 50 caracteres
        .Fields.Append .CreateField("cod_asig", dbText, 6)
        .Fields.Append .CreateField("nom_asig", dbText, 35)
        .Fields.Append .CreateField("rut_prof", dbText, 10)
        .Fields.Append .CreateField("nom_prof", dbText, 50)
        .Fields.Append .CreateField("curso", dbText, 6)
        .Fields.Append .CreateField("rut_prof_jefe", dbText, 10)
        .Fields.Append .CreateField("nom_prof_jefe", dbText, 50)
    End With
'    Next campos
'Next l
dbsTemp.TableDefs.Append tdfNuevo
dbsTemp.Close
Exit Sub
errores:
If Err.Number = 3010 Then
    dbsTemp.TableDefs.Delete NomTabla
    Resume
End If
End Sub

Private Sub llena_alumnos()

    Dim cod_ens_abr As String
    Dim bd As String
    Dim i As Integer
    Dim var_sql, Cod_Ens As String
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
   ' Dim REC As ADODB.Recordset
   ' Set REC = New ADODB.Recordset
    
    Select Case IC_Ensenanza.Text
        Case Is = "Educación Parvularia"
            Cod_Ens = "010"
            cod_ens_abr = "K"
        Case Is = "Educación General Básica"
            Cod_Ens = "110"
            cod_ens_abr = "B"
        Case Is = "Educación Media H/C niños y jóvenes"
            Cod_Ens = "310"
        Case Is = "Otros Tipos (Pre Kinder)"
            Cod_Ens = "996"
            cod_ens_abr = "PK"
        Case Is = "Play Group"
            Cod_Ens = "111"
            cod_ens_abr = "PG"
    End Select
    
    var_sql = "select des_jor,num_sal from cursos c,jornadas j" _
            & " where c.cod_jor = j.cod_jor and cod_ens = '" & Cod_Ens & "'" _
            & " and let_cur = '" & IC_Letra.Text & "' and num_gra = '" & Trim(IC_Nivel.Text) & "' and agno = '" & IC_Agno.Text & "'"
    objRS.Open var_sql, conn
    Frame2.Caption = "Jornada: " & objRS("des_jor") & "  -  Numero de Sala: " & objRS("num_sal")
    jornada.Caption = objRS("des_jor")
    objRS.Close
        
    curso = Trim(IC_Nivel.Text) & " " & IC_Letra.Text & " " & cod_ens_abr
    
    'Profe Jefe
    var_sql = "SELECT p.rut_prof,concat(noms_prof,' ', ape1_prof,' ', ape2_prof) as nom_prof_jefe FROM cursos c,profesores p" _
            & " WHERE c.rut_prof = p.rut_prof AND" _
            & " agno = " & IC_Agno.Text & " AND num_gra =  " & Trim(IC_Nivel.Text) _
            & " AND let_cur = '" & IC_Letra.Text & "' AND cod_ens = '" & Cod_Ens & "'"
    objRS.Open var_sql, conn
    profe_jefe.Caption = objRS("nom_prof_jefe")
    objRS.Close
            
    
    If Option1(0).Value = True Then
    var_sql = "select p.ci_alu as 'Rut',concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu)" _
           & " as 'nombre',mat.fec_mat as 'fec. matricula',fec_ing_curso as" _
           & " 'fec. ing. curso'" _
           & " From" _
           & " (select m.ci_alu,m.fec_mat,fec_ing_curso,fec_retiro" _
           & " from alu_x_cur axc,matriculas m" _
           & " Where m.Ci_alu = axc.Ci_alu And m.anno_mat = axc.agno And" _
           & " m.Num_Gra = axc.Num_Gra And m.Cod_Ens = axc.Cod_Ens" _
           & " and axc.cod_ens = '" & Cod_Ens & "' and axc.num_gra = " _
           & IC_Nivel.Text & " and axc.let_cur = '" & IC_Letra.Text & "' and" _
           & " axc.agno = " & IC_Agno.Text & " and axc.activo_alu = 'SI' and m.activo_alu = 'SI'" _
           & " and confirmado = 'SI' and fec_retiro = '1111-11-11') as mat left join" _
           & " postulantes as p on mat.ci_alu = p .ci_alu" _
           & " order by nombre"
    Else
    var_sql = "select p.ci_alu as 'Rut',concat(ape_pat_alu,' ',ape_mat_alu,' ',nom_alu)" _
            & " as 'nombre',mat.fec_mat as 'fec. matri.',fec_ing_curso as" _
            & " 'fec. ing. cur.',fec_cam as 'fec. cam.',fec_retiro as 'fec. ret.'," _
            & " nuevo as 'N. C.'From" _
            & " (select concat(num_gra_new,' ',let_cur_new) as 'nuevo',axc.ci_alu,m.fec_mat,fec_ing_curso,fec_cam,fec_retiro" _
            & " from alu_x_cur axc left join matriculas m" _
            & " on m.ci_alu = axc.ci_alu and m.anno_mat = axc.agno and" _
            & " m.num_gra = axc.num_gra and m.cod_ens = axc.cod_ens" _
            & " where axc.cod_ens = '" & Cod_Ens & "' and axc.num_gra = " & IC_Nivel.Text _
            & " and axc.let_cur = '" & IC_Letra.Text & "' and axc.agno = " & IC_Agno.Text & ")" _
            & " mat left join postulantes p on mat.ci_alu = p .ci_alu" _
            & " order by nombre"
    End If
    objRS.Open var_sql, conn
    If Not objRS.EOF Then
        Call Rec2Grid(objRS, grid_alumnos, True)
        If Option1(1).Value = True Then
            For i = 1 To grid_alumnos.Rows - 1
                If grid_alumnos.TextMatrix(i, 5) = "11/11/1111" Then
                    grid_alumnos.TextMatrix(i, 5) = ""
                End If
                If grid_alumnos.TextMatrix(i, 5) = "Null" Then
                    grid_alumnos.TextMatrix(i, 5) = ""
                End If
                If grid_alumnos.TextMatrix(i, 6) = "11/11/1111" Then
                    grid_alumnos.TextMatrix(i, 6) = ""
                End If
                If grid_alumnos.TextMatrix(i, 6) = "Null" Then
                    grid_alumnos.TextMatrix(i, 6) = ""
                End If
                If grid_alumnos.TextMatrix(i, 7) = "Null" Then
                    grid_alumnos.TextMatrix(i, 7) = ""
                End If
            Next i
'            Call CreaTablaReporte_alumnos(bd, "alumnos")
'            Call llenar_tabla_alumnos(bd, "alumnos")
        End If
        bd = App.Path & "\Rpt\pro_x_cur.mdb"
        Call llenar_tabla_alumnos(bd, "alumnos")
    Else
        MsgBox "La busqueda no arrojo resultados para el año " & IC_Agno.Text
    End If
    objRS.Close
End Sub

Private Sub CreaTablaReporte_alumnos(NomBd As String, NomTabla As String)
'On Error GoTo errores
Dim dbsTemp As Database
Dim NumCampos, TipoCampo As Integer
Dim tdfNuevo As TableDef
Set dbsTemp = OpenDatabase(NomBd)
'dbsTemp.TableDefs.Delete NomTabla
Set tdfNuevo = dbsTemp.CreateTableDef(NomTabla)
    With tdfNuevo
        .Fields.Append .CreateField("correlativo", adInteger)
        .Fields.Append .CreateField("rut_alu", dbText, 10)
        .Fields.Append .CreateField("nom_alu", dbText, 50)        ' Una cadena de 50 caracteres
        .Fields.Append .CreateField("fec_mat", dbDate)
        .Fields.Append .CreateField("fec_ing_cur", dbDate)
        .Fields.Append .CreateField("fec_cam", dbText)
        .Fields.Append .CreateField("fec_ret", dbText)
        .Fields.Append .CreateField("nue_cur", dbText)
    End With
'    Next campos
'Next l
dbsTemp.TableDefs.Append tdfNuevo
dbsTemp.Close
Exit Sub
errores:
If Err.Number = 3010 Then
    dbsTemp.TableDefs.Delete NomTabla
    Resume
End If
End Sub

Private Sub llenar_tabla_alumnos(bd As String, tabla As String)
Dim fec_ret, fec_cam, nue_cur As String
Dim dbsTemp As Database
Set dbsTemp = OpenDatabase(bd)
Dim var_sql As String
var_sql = "delete from " & tabla
dbsTemp.Execute var_sql
If grid_alumnos.Cols > 6 Then
    For i = 1 To grid_alumnos.Rows - 1
        fec_cam = IIf(grid_alumnos.TextMatrix(i, 5) = "", "11-11-1111", grid_alumnos.TextMatrix(i, 5))
        fec_ret = IIf(grid_alumnos.TextMatrix(i, 6) = "", "11-11-1111", grid_alumnos.TextMatrix(i, 6))
        nue_cur = IIf(grid_alumnos.TextMatrix(i, 7) = "", "S/C", grid_alumnos.TextMatrix(i, 7))
        var_sql = "insert into " & tabla & "(correlativo,rut_alu,nom_alu,fec_mat,fec_ing_cur,fec_cam,fec_ret,nue_cur)" _
                & " values(" & grid_alumnos.TextMatrix(i, 0) & ",'" & grid_alumnos.TextMatrix(i, 1) & "','" _
                & grid_alumnos.TextMatrix(i, 2) & "','" _
                & Format(grid_alumnos.TextMatrix(i, 3), "dd-mm-yyyy") & "','" _
                & Format(grid_alumnos.TextMatrix(i, 4), "dd-mm-yyyy") & "','" _
                & fec_cam & "','" _
                & fec_ret & "','" _
                & nue_cur & "')"
        dbsTemp.Execute var_sql
    Next i
Else
    For i = 1 To grid_alumnos.Rows - 1
        var_sql = "insert into " & tabla & "(correlativo,rut_alu,nom_alu,fec_mat,fec_ing_cur)" _
                & " values(" & grid_alumnos.TextMatrix(i, 0) & ",'" & grid_alumnos.TextMatrix(i, 1) & "','" _
                & grid_alumnos.TextMatrix(i, 2) & "','" _
                & Format(grid_alumnos.TextMatrix(i, 3), "dd-mm-yyyy") & "','" _
                & Format(grid_alumnos.TextMatrix(i, 4), "dd-mm-yyyy") & "')"
        dbsTemp.Execute var_sql
    Next i
End If
End Sub
