Results 1 to 9 of 9
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    list box based on combo box

    Within a form, I have a combo box and a list box. Here is the row source for the list box:

    SELECT tblWellData.WellID, tblWellData.CurrentWellName, tblWellData.CurrentOperator FROM tblWellData ORDER BY tblWellData.CurrentWellName;



    This displays all the records within the table. If I only want the records based on the selection within the combo box, this is the row source:

    SELECT tblWellData.WellID, tblWellData.CurrentWellName, tblWellData.CurrentOperator FROM tblWellData WHERE (((tblWellData.CurrentOperator)=[Forms]![frmTestForm]![Combo4])) ORDER BY tblWellData.CurrentWellName;

    It displays 0 records. What am I doing wrong?

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    What is the row source of the combo box? What is the bound field of the combo box?

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thank you for your quick reply.
    Here is the row source for the combo box:
    SELECT tblWellData.CurrentOperator FROM tblWellData GROUP BY tblWellData.CurrentOperator ORDER BY tblWellData.CurrentOperator;

    Bound column is 1

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    In the after update event of the combo box, you need to requery the list box. The code would be as follows (you will have to substitute your actual list box name)

    me.listboxname.requery

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Within the gotfocus of the listbox, I have me.requery. What's the difference between that and what you suggested?

  6. #6
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Your suggestion worked!! Thank you!!

    What's the difference between where the requery is done?

  7. #7
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    The after update event fires after a selection is made in the combo box. Since your list box depends on that value that event that will provide the WHERE clause with the value it needs. I did some experimenting and the code seems to work in the on click event as well.

    I use the after update event since it has been referenced on other websites, but like other things, there may be multiple ways to do things in Access.

  8. #8
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Within the form, I have other combo boxes source dependant upon another combo box. I've been using the requery within the gotfocus, and they work correctly. Thanks again for your assistance!!

  9. #9
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Now I've learned something new! Thanks

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

Similar Threads

  1. Replies: 1
    Last Post: 07-11-2012, 08:36 AM
  2. Replies: 1
    Last Post: 03-27-2012, 07:10 AM
  3. Replies: 5
    Last Post: 03-12-2012, 02:58 AM
  4. Replies: 1
    Last Post: 02-03-2012, 03:51 PM
  5. Replies: 33
    Last Post: 01-13-2012, 07:44 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