Tema: Boton
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/06/2010, 07:56
Avatar de pkj
pkj
 
Fecha de Ingreso: julio-2006
Ubicación: Órbita sincrónica
Mensajes: 899
Antigüedad: 17 años, 8 meses
Puntos: 29
Respuesta: Boton

No entiendo mucho, pero imagino que será algo así:

Código vb:
Ver original
  1. Private Sub cmdBuscar_Click()
  2.  
  3.   If cmbHorario = "" and txtFecha = "" Then
  4.     MsgBox ("Ingrese Hora y/o Fecha. Gracias")
  5.     Exit Sub
  6.   End If
  7.  
  8.   If cmbHorario <> "" and txtFecha = "" Then
  9.     rst.Open "Select * from Vespertino where Horario='" & Me.cmbHorario & "'", CBD, adOpenKeyset, adLockBatchOptimistic
  10.     If Not rst.EOF Then
  11.       txtProfesor.Text = rst("NombreMaestro")
  12.       cmbHorario.Text = rst("Horario")
  13.       txtMateria.Text = rst("Materia")
  14.       txtGrupo.Text = rst("Grupos")
  15.       txtEquipo.Text = rst("Equipo")
  16.       txtFecha.Text = rst("Fecha")
  17.       txtFolio.Text = rst("NoReunion")
  18.       cmbHorarioSalida.Text = rst("HorarioSalida")
  19.     End If
  20.   ElseIf cmbHorario = "" and txtFecha <> "" Then
  21.     rst.Open "Select * from Vespertino where Fecha='" & Me.txtFecha & "'", CBD, adOpenKeyset, adLockBatchOptimistic
  22.     If Not rst.EOF Then
  23.       txtProfesor.Text = rst("NombreMaestro")
  24.       cmbHorario.Text = rst("Horario")
  25.       txtMateria.Text = rst("Materia")
  26.       txtGrupo.Text = rst("Grupos")
  27.       txtEquipo.Text = rst("Equipo")
  28.       txtFecha.Text = rst("Fecha")
  29.       txtFolio.Text = rst("NoReunion")
  30.       cmbHorarioSalida.Text = rst("HorarioSalida")
  31.     Else
  32.       MsgBox "HORA LIBRE"
  33.       txtProfesor = ""
  34.       cmbHorario.Text = ""
  35.       txtMateria.Text = ""
  36.       txtGrupo.Text = ""
  37.       txtEquipo.Text = ""
  38.       txtFecha.Text = ""
  39.       txtFolio.Text = ""
  40.       cmbHorarioSalida.Text = ""
  41.     End If
  42.   Else
  43.     rst.Open "Select * from Vespertino where Horario='" & Me.cmbHorario & "' and Fecha='" & Me.txtFecha & "'" , CBD, adOpenKeyset, adLockBatchOptimistic
  44.     If Not rst.EOF Then
  45.       txtProfesor.Text = rst("NombreMaestro")
  46.       cmbHorario.Text = rst("Horario")
  47.       txtMateria.Text = rst("Materia")
  48.       txtGrupo.Text = rst("Grupos")
  49.       txtEquipo.Text = rst("Equipo")
  50.       txtFecha.Text = rst("Fecha")
  51.       txtFolio.Text = rst("NoReunion")
  52.       cmbHorarioSalida.Text = rst("HorarioSalida")
  53.     Else
  54.       MsgBox "HORA LIBRE"
  55.       txtProfesor = ""
  56.       cmbHorario.Text = ""
  57.       txtMateria.Text = ""
  58.       txtGrupo.Text = ""
  59.       txtEquipo.Text = ""
  60.       txtFecha.Text = ""
  61.       txtFolio.Text = ""
  62.       cmbHorarioSalida.Text = ""
  63.     End If
  64.  
  65.   End If
  66.   rst.Close
  67.  
  68. End Sub

Te falla el msgbox posiblemente porque te falta un End If.

Estructura el código para poder notar cuando una sección no se ha cerrado correctamente.
Ejm: un Do sin Loop, un For sin Next, etc.

Saludos
__________________
No hay preguntas tontas, solo gente estup..., ¡No!, ¿como era? No hay gente que pregunte a tontos... ¡Nooo!... ¡Vaya cabeza!