Results 1 to 4 of 4

Thread: [RESOLVED] combo boxes restricted by combo boxes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    29

    Resolved [RESOLVED] combo boxes restricted by combo boxes

    I have a form where I have two combo boxes and i want to restrict the second combo box based on what was put in the first combo box. I've seen about 5 different websites that explain step by step how to do it, and im really really close, but don't quite have it and i hope someone can help. Right now when i click on the second combo box a screen pops up asking me the value of my first combo box, once i enter that, it restricts the second combo box, but i want to bypass the pop up screen and have it find that value automatically. Anyone know what I'm doing wrong? Thanks in advance!

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: combo boxes restricted by combo boxes

    How are you populating your comboboxes from a database ? or some other way ?

    Normally if i wanted to do this i would have 1 combobox populated from a database table.

    Then on Selection i would run some code to do another query with the value of the combobox in the Where clause !!

    e.g - (Returns the Cities for A Selected Country)
    Code:
    Private sub cboCountry_Click()
    
    If cboCountry.Text <> "" then
          GetCities cboCountry.Text
    End If
    
    End Sub
    
    Private Sub GetCities(strCountry as String)
    
    dim StrSQL as string
    
    strSQL = "SELECT Cities From City_Table WHERE Country = '" & strCountry & "'"
    
    ' then use you database class to connect to your database and  to run your sql. This will return a Recordset which you can loop through and add the Values to your Other Combo box
    
    End Sub

    Are you using a Database or are you trying to do this some other way like with Array's or something ????

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    29

    Re: combo boxes restricted by combo boxes

    Thank you for your response. my form is called frmQryClarifiers . I have the first combo box (combo24) set-up with a contact from a table called tblJobs. This table is also the one where all new data is being stored (I dont know if that will have an effect on things). in that row source I have typed SELECT [tblJobs].[Contractor] FROM tblJobs; and in the after update event i have the code
    vb Code:
    1. Private Sub Combo24_AfterUpdate()
    2. [Forms]![frmQryClarifiers]![Combo28].Requery
    3. [Forms]![frmQryClarifiers]![Combo28].SetFocus
    4. End Sub
    Combo28 is the second combo box. Under row source for that box i have SELECT [tblJobs].[Cntr_Addr1] FROM tblJobs WHERE ((([tblJobs]![Contractor])=frmQryClarifiers!Combo24));

    Like before the problem is a window coming up that states:
    Enter Parameter Value
    frmQryClarifiers!Combo24

    And I'm just using Access as a database to do this.
    Thanks!

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    29

    Re: combo boxes restricted by combo boxes

    Nevermind, Resloved!

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