
condicion if, else
Publicado por rosy (12 intervenciones) el 24/03/2016 17:43:24
Hola buen dia, solicito de su ayuda por favor!! veran tengo este codigo de VB el cual quiero que ejecute el "macro3" SOLO cada vez que se cumpla la condicion:
Sin embargo el macro se ejecuta tanto con esa condicion como con esta:
Me podrian decir que debo corregir para que solo se ejecute cuando cumpla la primer condicion por favor??
Este es el codigo completo:, de antemano muchisisimas gracias
1
2
3
4
5
sqlquery = "Insert into SerialesCreados(Serial,Fecha) Values('" & Ser.text & "','" & Date & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlquery
DoCmd.SetWarnings True
Ser.BackColor = RGB(0, 255, 0)
Sin embargo el macro se ejecuta tanto con esa condicion como con esta:
1
2
3
4
5
6
7
Case Is = Combo30
serint = DLookup("Serial", "Historial Seriales Creados", "Serial='" & Ser.text & "'") & DLookup("Serial", "SerialesCreados", "Serial='" & Ser.text & "'")
If Not serint = "" Then
Ser.BackColor = RGB(255, 0, 0)
response1 = msgbox("El Serial Existe", vbOKOnly, "Atencion")
If response1 = vbOK Then
DoCmd.OpenForm "Login"
Me podrian decir que debo corregir para que solo se ejecute cuando cumpla la primer condicion por favor??
Este es el codigo completo:, de antemano muchisisimas gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Private Sub ser_afterUpdate()
If Not Ser.text = "" Then
Select Case Text48
Case Is <> Combo30
Response = msgbox("Numero de Parte Incorrecto", vbyesNo, "Atencion")
If Response = vbYes Then
DoCmd.OpenForm "Login"
Else
DoCmd.CloseDatabase
'
End If
Case Is = Combo30
serint = DLookup("Serial", "Historial Seriales Creados", "Serial='" & Ser.text & "'") & DLookup("Serial", "SerialesCreados", "Serial='" & Ser.text & "'")
If Not serint = "" Then
Ser.BackColor = RGB(255, 0, 0)
response1 = msgbox("El Serial Existe", vbOKOnly, "Atencion")
If response1 = vbOK Then
DoCmd.OpenForm "Login"
End If
Else
sqlquery = "Insert into SerialesCreados(Serial,Fecha) Values('" & Ser.text & "','" & Date & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlquery
DoCmd.SetWarnings True
Ser.BackColor = RGB(0, 255, 0)
End If
End Select
End If
DoCmd.RunMacro "macro3", 1
Ser = ""
Me.Text123.Value = Val(Text123.Value) + 1
If Val(Me.Text123.Value) < Me.Text35.Value Then
End If
If Me.Text123.Value = Me.Text35 Then
DoCmd.OpenForm "form3"
End If
End If
End Sub
Valora esta pregunta


0