Hola de nuevo,
Dando una vuelta al tema, he interpretado que quizá la solución que buscabas era otra. Si lo que buscabas era aflorar el concepto 'folio' partiendo del resto de variables, quizá el archivo adjunto te dé una idea de cómo abordar la solución.
He corregido algunos importes, para confirmar que la asignación recoja los resultados más probables.
Saludos,
Base 05 (C).xlsx
Por
Victor7, · 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