Results 1 to 10 of 10
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Binding a list box

    I have a form, [frmRptCTWEntry]. I have two list boxes, [lstSubjectInReport] and [lstSubjectXCTWLocation]. [lstSubjectInReport] is bound to the form. However, I want the second list box, [lstSubjectXCTWLocation], bound to the first list box. So, when the user selects a record from the first list box, the second list box changes to match it. How do I do this?

  2. #2
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I'm getting an error I don't understand. When I click on the first list box, [lstSubjectInReport], I get this:
    "Control can't be edited; it's bound to Autonumber field 'ReportID'

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I couldn't figure it out. So, what I did was to create a query based on the first list box. Then, I made the second list box based on that query. It seems to work, but I haven't put it to a hard test yet. Does that sound like a decent solution? Also, I can't get the first list box, [lstSubjectInReport] to work right. If I have multiple records in that list box, it will only select the first.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Don't bind to an autonumber field. That is attempting to save the selected value into field. Controls whose purpose is just to select filter criteria must be unbound. Bind a control when you want to save the value into record.
    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.

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I have the list box unbound. The error is gone. I need to get the next list box to work. The list box, [lstTrespassedFrom], the SQL:
    SELECT [SubjectID], [BldgName] FROM qryCTWTrespassedFrom ORDER BY [BldgName];

    The query, [qryCTWTrespassedFrom]:
    Click image for larger version. 

Name:	query.jpg 
Views:	22 
Size:	83.5 KB 
ID:	33481
    The query isn't returning anything. Can it get the [SubjectID] from a list box?

  6. #6
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I forgot to put the SQL for the list box, [lstSubjectInReport]:
    SELECT [SubjectID], [ReportID], [LastName], [FirstName], [MidName], [DOB] FROM qryCTWSubjectInReport ORDER BY [LastName], [FirstName];

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    This is cascading (dependent) combo or list box. Common topic. Need WHERE clause in second listbox that references the first. Then code in some event to requery the listbox. The real trick is figuring out which event(s).
    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.

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Thanks. I couldn't figure it out. I'm looking up and trying to figure out the cascading combo. In the meantime, I used subforms. They're working fine right now. When I learn more, I'll change them to list boxes. Thanks again.

  9. #9
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Don't know if this will help, but here is a dB I created to learn how to set up cascading combo/list boxes.

    There are a couple of design errors I haven't taken the time to fix. One is naming objects (tables) beginning with a number.... shouldn't do that.

    But you can tear it apart to see how things are linked and how the code works. There is a form for cascading combo boxes and a form for cascading list boxes (helped me to see how things were linked).
    Attached Files Attached Files

  10. #10
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Thanks. I'll check it out.

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

Similar Threads

  1. excel binding issue i think...
    By trevor40 in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2015, 04:47 PM
  2. Form and Binding Records
    By KirstyP in forum Forms
    Replies: 10
    Last Post: 01-12-2015, 09:53 PM
  3. Binding Help
    By kgbo in forum Forms
    Replies: 1
    Last Post: 08-15-2013, 11:50 AM
  4. Binding a checkbox to a subform
    By Bhat59 in forum Forms
    Replies: 3
    Last Post: 10-20-2011, 08:48 PM
  5. Binding 'count' <>1 to appropriate key
    By Captain Database ...!! in forum Queries
    Replies: 2
    Last Post: 06-09-2011, 06:44 PM

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