Results 1 to 8 of 8

Thread: [RESOLVED] Combo trick?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    61

    Resolved [RESOLVED] Combo trick?

    Once again hello,

    First id look for some particular thread which is similar to my app, but i stumble on an empty wall, here's what i want to do i have combo1 and combo2 , when the user select combo1 and choose a particular list on it " combo1" eg.

    here is list in combo1 ----- Action
    Suspence
    Thriller
    Drama
    when the user select "Action"

    combo 2 would display all the list in "Action" Movie
    ------Die Another Day
    ------Italian Job
    ------MI3



    please see attached file thank you once again.

    ------------------------------------------
    Private Sub Combo1_DropDown()
    Combo1.Clear
    Combo1.AddItem "Action"
    Combo1.AddItem "Drama"
    Combo1.AddItem "Comedy"
    End Sub
    Attached Files Attached Files

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Combo trick?

    i could not see your attachement as i do not have that facility in my system...could you post what is your problem
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Combo trick?

    do you mean to do this
    VB Code:
    1. Private Sub Combo1_Click()
    2.     Combo2.Clear
    3.     If Combo1.Text = "Action" Then
    4.         'ad list of action films here
    5.         Combo2.AddItem "Die Another Day"
    6.         Combo2.AddItem "Italian Job"
    7.         Combo2.AddItem "MIB"
    8.     ElseIf Combo1.Text = "Drama" Then
    9.         'add list of drama films here
    10.     Else
    11.         'add list of comedy films here
    12.     End If
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16.     Combo1.Clear
    17.     Combo1.AddItem "Action"
    18.     Combo1.AddItem "Drama"
    19.     Combo1.AddItem "Comedy"
    20. End Sub
    Last edited by d3gerald; Mar 30th, 2006 at 01:34 AM.
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    61

    Re: Combo trick?

    Private Sub Combo1_Click()
    Combo2.Clear
    If Combo1.Text = "Action" Then
    'ad list of action films here
    Combo2.AddItem "Die Another Day"
    Combo2.AddItem "Italian Job"
    Combo2.AddItem "MIB"
    ElseIf Combo1.Text = "Drama" Then
    Combo2.AddItem "alone"
    Combo2.AddItem "my foe"
    Else

    ElseIf Combo1.Text = "Comedy" Then
    Combo2.AddItem "Bruce almighty"
    Combo2.AddItem "Stuart little"

    End Sub

    Private Sub Form_Load()
    Combo1.Clear
    Combo1.AddItem "Action"
    Combo1.AddItem "Drama"
    Combo1.AddItem "Comedy"
    End Sub




    why i do get this error

    "else if with error", i mis something here right?

    by the way ganes, its like a selection with condition master d3gerald is correct but i know missd some "if" or else statement here.

    cheers

  5. #5
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Combo trick?

    See the red bit
    VB Code:
    1. Private Sub Combo1_Click()
    2.     Combo2.Clear
    3.     If Combo1.Text = "Action" Then
    4.         'ad list of action films here
    5.         Combo2.AddItem "Die Another Day"
    6.         Combo2.AddItem "Italian Job"
    7.         Combo2.AddItem "MIB"
    8.     ElseIf Combo1.Text = "Drama" Then
    9.         'add list of drama films here
    10.     Else
    11.         'add list of comedy films here
    12.     [color=red]End If[/color]     ' This should be End If NOT End Sub
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16.     Combo1.Clear
    17.     Combo1.AddItem "Action"
    18.     Combo1.AddItem "Drama"
    19.     Combo1.AddItem "Comedy"
    20. End Sub
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  6. #6
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Combo trick?

    the problem lies with the elseif you have after the else. you cannot put elseif after else.

    yet you can do the other way around
    elseif.....
    elseif....
    else

    then also make sure that if you have an if opening statement, you must have an end if as its closing
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    61

    Re: Combo trick?

    Private Sub Combo1_Click()
    Combo2.Clear
    If Combo1.Text = "Action" Then
    'ad list of action films here
    Combo2.AddItem "Die Another Day"
    Combo2.AddItem "Italian Job"
    Combo2.AddItem "MIB"
    ElseIf Combo1.Text = "Drama" Then
    Combo2.AddItem "alone"
    Combo2.AddItem "fear"

    ElseIf Combo1.Text = "Comedy" Then
    Combo2.AddItem "bruce"
    Combo2.AddItem "stuart little"
    Else
    End If

    End Sub

    Private Sub Form_Load()
    Combo1.Clear
    Combo1.AddItem "Action"
    Combo1.AddItem "Drama"
    Combo1.AddItem "Comedy"
    End Sub

    walla thanks master i got it right your heaven sent....
    i hope this thread can help other too.

    cheers...:-)

  8. #8
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: [RESOLVED] Combo trick?

    Hi
    It's my suggest:

    VB Code:
    1. Option Explicit
    2. Dim i%
    3. Private Sub Combo1_Click()
    4.  
    5.    For i = 0 To Combo2.ListCount - 1
    6.       Combo2.RemoveItem 0
    7.    Next
    8.    
    9.    If (Combo1.ListIndex = 0) Then
    10.       Call Load_One
    11.    ElseIf (Combo1.ListIndex = 1) Then
    12.       Call Load_Two
    13.    Else
    14.       Call Load_Three
    15.    End If
    16.    
    17. End Sub
    18.  
    19. Private Sub Load_One()
    20. Combo2.AddItem "Womans"
    21. Combo2.AddItem "Teri"
    22. Combo2.AddItem "Tania"
    23. Combo2.AddItem "Tina"
    24. Combo2.AddItem "Theodory"
    25. Combo2.ListIndex = 0
    26. End Sub
    27.  
    28. Private Sub Load_Two()
    29. Combo2.AddItem "Mens"
    30. Combo2.AddItem "Rudolf"
    31. Combo2.AddItem "Robert"
    32. Combo2.AddItem "Richard"
    33. Combo2.AddItem "Rod"
    34. Combo2.ListIndex = 0
    35. End Sub
    36. Private Sub Load_Three()
    37. Combo2.AddItem "Childs"
    38. Combo2.AddItem "Kiki"
    39. Combo2.AddItem "Nico"
    40. Combo2.AddItem "Jesee"
    41. Combo2.AddItem "Kes"
    42. Combo2.ListIndex = 0
    43. End Sub
    I know, I know, my English is bad, sorry .....

Posting Permissions

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



Click Here to Expand Forum to Full Width