Results 1 to 4 of 4
  1. #1
    billcar2006 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2014
    Posts
    13

    Combo box that filters the rowsource

    I have a combo box on a form that when I start typing it gives me a dropdown menu of all part names that start with what I type, then I can select which one I want and it goes to that record. This works fine with the code below. I want to add in another criteria.
    I also have another combo box called cboMachine on the form, that's controlsource is Machine which is in the same table as part Name. I reckon I have to add to this line strRowSource = "SELECT ID, [Part Name] FROM [Part Details]"
    What I need to put and where I don't know. If anyone could help that would be much appreciated.

    Private Sub cbomachineSelect_Change()
    Dim strRowSource As String
    strRowSource = "SELECT ID, [Part Name] FROM [Part Details]"
    If Len(Me!cbomachineSelect.Text) = 4 Then
    strRowSource = strRowSource & " WHERE [Part Name] Like '"
    strRowSource = strRowSource & Me!cbomachineSelect.Text
    strRowSource = strRowSource & "*'"
    Me!cbomachineSelect.RowSource = strRowSource
    Me!cbomachineSelect.Dropdown
    End If


    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    This is cascading (dependent) combo/list boxes. Should be aware will not work nice in Datasheet or Continuous view.

    I am not sure from your post which combo is dependent. Review http://www.datapigtechnologies.com/f...combobox2.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    billcar2006 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2014
    Posts
    13
    The combos are not dependant. CboMachine gets its data from a machine table and puts it in part details table depending which machine I select with cboMachine. cboMachineselect I should have renamed to cboPartName to avoid confusion. This combo only jumps the form to the record with the part name selected in it. With this combo when I start type in the first 5 letters of the part name the combo drops down and shows all the part names in the table that begin with those 5 letters.
    I have already filtered the form with the machine so it only shows the records for that machine. But when I type into the cboPartName combo it still shows all the part names because the code above is setting the record source from the table.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Sorry then. Don't understand what you need.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-14-2012, 04:40 PM
  2. RowSource question
    By ermcc in forum Access
    Replies: 3
    Last Post: 07-11-2012, 08:16 AM
  3. .RowSource Combo
    By white_flag in forum Access
    Replies: 1
    Last Post: 09-06-2011, 07:59 AM
  4. Combo Box Filters for custom navigation
    By hobsondm01 in forum Forms
    Replies: 1
    Last Post: 07-05-2011, 09:58 AM
  5. SQL Rowsource
    By DSTR3 in forum Queries
    Replies: 2
    Last Post: 12-06-2010, 11:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums