Saltar al contenido

Problema con Setfocus


JDG

Recommended Posts

publicado

Hola amig@s

Tengo un problema que no doy con el.

En el códigos siguiente, el Setfocus no “funciona”…

¿Qué estoy haciendo mal?...

De repente estoy trancado en alguna tontería pero ya “no veo” ja!.

Me podrias ayudar?

 

Gracias de antemano.

 

 

Private Sub cmdAceptar_click()

Application.ScreenUpdating = False

   

                    If Trim(Me.txt_fecha) = Empty Then

                        Me.txt_fecha.BackColor = &HC0C0FF

                        MsgBox "Debe ingresar la fecha de la operación", , "CAMPO VACIO"

                        Me.txt_fecha.SetFocus

                        Me.txt_fecha.SelStart = 0

                        Exit Sub

 

                            ElseIf Trim(Me.txt_Descripcion) = "" Then

                                Me.txt_Descripcion.BackColor = &HC0C0FF

                                MsgBox "Detalle la operacion", , "CAMPO VACIO"

                                Me.txt_Descripcion.SetFocus

                                Me.txt_Descripcion.SelStart = 0

                                Exit Sub

                               

                                    ElseIf me.cbx_Naturaleza = "" Then

                                        Me.cbx_Naturaleza.BackColor = &HC0C0FF

                                        MsgBox "Seleccione Naturaleza de la operación", , "CAMPO VACIO"

                                        Me.cbx_Naturaleza.SetFocus

                                        Me.cbx_Naturaleza.SelStart = 0

                                        Exit Sub

                                       

                                            ElseIf Me.cbx_Operacion = "" Then

                                                Me.cbx_Operacion.BackColor = &HC0C0FF

                                                MsgBox "Seleccione tipo de Operacion", , "CAMPO VACIO"

                                                Me.cbx_Operacion.SetFocus

                                                Me.cbx_Operacion.SelStart = 0

                                                Exit Sub

                                               

                                                    ElseIf Me.cbx_Fondo = "" Then

                                                        Me.cbx_Fondo.BackColor = &HC0C0FF

                                                        MsgBox "Seleccione Fondo afectado", , "CAMPO VACIO"

                                                        Me.cbx_Fondo.SetFocus

                                                        Me.cbx_Fondo.SelStart = 0

                                                        Exit Sub

                                                       

                                                            ElseIf Me.txt_Importe = "" Then

                                                                Me.txt_Importe.BackColor = &HC0C0FF

                                                                MsgBox "Ingrese el Importe", , "CAMPO VACIO"

                                                                Me.txt_Importe.SetFocus

                                                                Me.txt_Importe.SelStart = 0

                                                                Exit Sub

                                                                

                                                                    ElseIf Not IsDate(Me.txt_fecha.Value) Then 'verifica que sea una fecha valida

                                                                        Me.txt_fecha.BackColor = &HC0C0FF

                                                                        MsgBox "Fecha invalida.", vbCritical, "   ERROR !"

                                                                        Me.txt_fecha.SetFocus

                                                                        Me.txt_fecha.SelStart = 0

                                                                        Exit Sub

                                                                       

                                                                            ElseIf Me.cbx_Naturaleza.Text = "Egresos" And Me.txt_Importe.Value > 0 Then

                                                                                Me.txt_Importe.BackColor = &HC0C0FF

                                                                                MsgBox "Debe ser importe negativo", vbCritical, "   ERROR !"

                                                                                Me.txt_Importe.SetFocus

                                                                                Me.txt_Importe.SelStart = 0

                                                                                Exit Sub

                                                                                    

                                                                                    ElseIf Me.cbx_Naturaleza.Text = "Ingresos" And Me.txt_Importe.Value < 0 Then

                                                                                        Me.txt_Importe.BackColor = &HC0C0FF

                                                                                        MsgBox "Debe ser importe positivo", vbCritical, "   ERROR !"

                                                                                        Me.txt_Importe.SetFocus

                                                                                        Me.txt_Importe.SelStart = 0

                                                                                        Exit Sub

 

               

                    End If

publicado

Hola

Prueba quitando la propiedad SelStart a ver que sucede.

Puedes adjuntar tu archivo para ver como se ejecuta.

 

Saludos.

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.