Results 1 to 8 of 8

Thread: ComboBox results linked to specific Form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    ComboBox results linked to specific Form

    I have a ComboBox on Form1 with a list of about 40 specific names from the drop down list. Example Site 1, Site 2, Site 3 etc... What I'd like is, if you select say Site 1 from the drop down menu it would go to Form2. Thanks in advance!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: ComboBox results linked to specific Form

    Why not use a menu as a menu?

    Barring that, what's the question? Use a Select Case or equivalent for your various actions.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Re: ComboBox results linked to specific Form

    Quote Originally Posted by dilettante View Post
    Why not use a menu as a menu?

    Barring that, what's the question? Use a Select Case or equivalent for your various actions.
    Sorry, but I do not know how to write a Select Case statement

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: ComboBox results linked to specific Form

    from form2
    Code:
    text1 = form1.combo1.text
    change form names and controls to suit

    or you can do the same from form1 by prefixing the control on form2 with the form name, even before you show form2
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Re: ComboBox results linked to specific Form

    Attachment 181687 Not sure what text1 is referring to. Basically if Site 1 is selected from drop down menu then open Form2

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Re: ComboBox results linked to specific Form

    Just figured it out. Thanks anyway for any help. I was trying to hard!
    Private Sub Combo1_Click()
    If "Site 1" = Form1.Combo1.Text Then
    Form2.Show
    Form1.Hide
    End If
    End Sub

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: ComboBox results linked to specific Form

    Select case is pretty simple and is easy to find examples of how to use it, all you have to do is look.

    Code:
    Select Case Combo1.Text
    
    Case "Site 1"
       'some code here to do what you want in that case
    Case "Site 2"
        ' some code here to handle this case
    'and so on as many cases as is needed
    
    End Select

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: ComboBox results linked to specific Form

    Welcome to the Forum.
    Sam I am (as well as Confused at times).

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