dcsimg
Results 1 to 6 of 6

Thread: Form is Showing when it's not Supposed to

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Location
    San Diego
    Posts
    16

    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

    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
    Last edited by betogm; Mar 16th, 2016 at 01:11 PM.

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,073

    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


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,293

    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?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Location
    San Diego
    Posts
    16

    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.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Location
    San Diego
    Posts
    16

    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.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Location
    San Diego
    Posts
    16

    Re: Form is Showing when it's not Supposed to

    I have edited my code to further clarify

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width