Form is Showing when it's not Supposed to
Hello everyone,
I am having quite a bit of trouble with a form being called when a condition is met. The problem is that it's showing even when the condition is not met :mad:
Can you please help me with my dilemma? Thanks!
Code:
Cmd.CommandText = "SELECT descripcion FROM re_sucursal WHERE estatus = 1 AND re_id_cliente = '" & x & "'"
Set rs = Cmd.Execute
If rs("descripcion").Value = "prueba" Then
respuesta = MsgBox("Question?", vbYesNo, "Error")
If respuesta = vbNo Then
Exit Sub
ElseIf respuesta = vbYes Then
Load Form9
If Combo4.text = "Nombre Cliente" Then
Form9.Combo4.text = "Nombre Cliente"
Form9.Combo1.text = Combo1.text
Form9.Command1.Value = True
Form9.Command4.Value = True
'Form9.Show
Else
Form9.Combo4.text = "Numero Cliente"
Form9.Combo1.text = Combo1.text
Form9.Command1.Value = True
Form9.Command4.Value = True
'Form9.Show
End If
Form9.Show
End If
Else
Form9.Hide
Unload Form9
End If
Re: Form is Showing when it's not Supposed to
The only thing I see is that you hide Form9 when condition is not true otherwise you show Form9. Are you absolutely sure that conditions is ever 'not true'. Check all places where you set condition and when you see that you have made it false see if it calls your above code
Also you might want to change ElseIf respuesta to just Else
Re: Form is Showing when it's not Supposed to
Seems to work fine here for me - how is the condition variable dimmed and set?
Re: Form is Showing when it's not Supposed to
Thanks for your quick reply. I am using break points from visual studio 6 and I can see when the condition is not met. It doesn't even go into the code of the condition. Which is why it's strange for me for that to happen.
Re: Form is Showing when it's not Supposed to
The condition variable is an ADO recordset. I check if a customer has an address. If not ask the user if they want to add it, if so open Form9, if not keep going.
How do I know the condition is not met? The question "question?" is never asked yet the form is still loaded.
Re: Form is Showing when it's not Supposed to
I have edited my code to further clarify