Results 1 to 4 of 4
  1. #1
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83

    Filter List box from combo box selection

    I have done this many times but, for some reason, the code just will not work for me in this instance. I am just trying to fill an unbound list box (lstSpec) on my form with the specialtyid in my table tblSpecialty_by_SME, linked to the SMEID in tblSME. I had it working, db corrupted so I lost it and can't seem to re-create. I know it's simple!

    Row source for my combo box cboSME:

    SELECT tblSME.SMEID, tblSME.SME, tblSME.[Date Added], tblSME.Location, tblSME.[email address], tblSME.[FY'12 Participation Goal], tblSME.[Facilitation Course Completed], tblSME.[Content Train the Trainer Completed], tblSME.[Pilot Course Taught], tblSpecialty_by_SME.specialtyid
    FROM tblSpecialty INNER JOIN (tblSME INNER JOIN tblSpecialty_by_SME ON tblSME.SMEID = tblSpecialty_by_SME.smeid) ON tblSpecialty.SpecialtyID = tblSpecialty_by_SME.specialtyid;



    After update event of cboSME:

    Private Sub cboSME_AfterUpdate()
    Dim strSource As String
    Me.lstSpec.SetFocus

    strSource = "SELECT smeid,specialtyid " & _
    "FROM tblSpecialty_by_SME " & _
    "WHERE smeid = " & Me.cboSME.Column(0) & _
    "ORDER BY specialtyid"
    Me.lstSpec.RowSource = strSource

    Any ideas as to what I am doing wrong on this one?

    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assume smeid is a numeric data type? Try adding a space before ORDER BY. As is, the smeid value will be jammed into it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83
    You assumed correctly, I knew it was something simple I was missing - thank you for your quick response!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. List Box Selection transfer
    By kulle in forum Programming
    Replies: 5
    Last Post: 08-16-2011, 11:59 AM
  2. Replies: 4
    Last Post: 04-05-2011, 06:12 PM
  3. Replies: 1
    Last Post: 11-23-2010, 01:30 PM
  4. Checking List Box Value with Combo box selection
    By empyrean in forum Programming
    Replies: 1
    Last Post: 10-23-2009, 06:01 PM
  5. Replies: 1
    Last Post: 08-26-2009, 10:45 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