A ver si me pueden ayudar, la verdad que me estoy rompiendo el cerebro tratando de entender lo que sucede. Veamos lo que sucede es que este codigo lo saque desde una pagina, funciona a la perfecion hasta la "Case 21", ya que no funciona, esto se
debe a que el si bien el recordset esta ordenado por HORA, al recorrer los controles primero encuentra siempre los txtNota21, txtNota22....... txtNota38, txtNota0, txtNota1.... hasta el 20. Razon por la cual nunca se logra la igualdad para los txtNota 21,
txtNota22..... hasta txtNota38. Yo lo que necesito es que me recorra los controles desde txtNota0, txtNota1........ hasta txtNota37 y txtNota38, o sea en orden correlativo. ya asigne el TabIndexde acuerdo a mis deseos, pero al ejecutar el codigo no lo respeta,
que podra ser y como poder corregirlo?
'*******************************************************************************
'* CargarNotas
'* recupera y muestra las notas del día mostrado
'* Argumentos: datFecha => fecha a mostrar
'* uso: CargarNotas datFecha
'* ESH 07/11/06 19:50
'*******************************************************************************
Public Sub CargarNotas(datFecha As Date)
Dim i As Variant
Dim ctl As Control, _
rst As DAO.Recordset, _
strSQL As String
' abro un recordset con la tabla notas
On Error GoTo CargarNotas_TratamientoErrores
strSQL = "SELECT Dia, Hora, Nota,Confirma "
strSQL = strSQL & " FROM tblNotas "
strSQL = strSQL & " WHERE " & BuildCriteria("Dia", dbDate, "=" & datFecha)
strSQL = strSQL & " ORDER BY Hora"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
' recorro los controles del formulario verificando si empiezan por txtNota
For Each ctl In Me.Controls
If Left(ctl.Name, 7) = "txtNota" Then
If Not (rst.EOF) Then
If Not rst.EOF Then
If Val(Mid(ctl.Name, 8)) = rst!Hora Then
ctl.Value = rst!Nota
Select Case rst!Hora
Case 1
verificacion_1 = rst!Confirma
Case 2
verificacion_2 = rst!Confirma
Case 3
verificacion_3 = rst!Confirma
:
:
:
Case 19
verificacion_19 = rst!Confirma
Case 20
verificacion_20 = rst!Confirma
Case 21
verificacion_21 = rst!Confirma
Case 22
verificacion_22 = rst!Confirma
Case 23
verificacion_23 = rst!Confirma
Case 24
verificacion_24 = rst!Confirma
End Select
If Not rst.EOF Then rst.MoveNext
End If
End If
Else
ctl.Value = ""
End If
End If
Next ctl
CierraRecordsetDAO rst
CargarNotas_Salir:
On Error GoTo 0
Exit Sub
CargarNotas_TratamientoErrores:
MsgBox "Error " & Err.Number & " en proc.: CargarNotas de Documento VBA: Form_frmTaco (" & Err.Description & ")"
Resume CargarNotas_Salir
End Sub ' CargarNotas