Results 1 to 3 of 3
  1. #1
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    119

    ComboBox Doesn't Display A Value for Existing Records when Browsing through the Form

    Hello all,



    I have a form that fills a table called tblInspections. Among many other fields, tblInspections has the following fields: DistrictNumber, SectionNumber, MunicipalityID, and InspectionSiteID. All are foreign keys that refer to their own separate tables where they are primary keys.

    They way it works is that a whole area is divided into districts, and each district is divided into sections, and each section can fall in one of the many towns/cities that have been defined by state government. Thus, I have a tblInspectionSites that lists all current sites and their districts, sections, and municipalities. Each site is distinguished by a site number.

    For frmInspections, I use option groups to set the district and section numbers. Using these values, I have a combobox linked to a query that finds all municipalities that happen to fall in that combination of District and Section. This query populates the dropdown choice list. Once this is set, the InspectionSiteID also uses a combobox that uses a query that filters all inspection site by the district, section, and municipality selected to populate the dropdown choices. (To refresh the queries, I have each combobox requery on GotFocus.)

    Now this all works when I'm inputting a record. However, when I'm browsing through previous records, the comboboxes display as empty even though the table does have values stored for them. I think this is because the most recent query for each combobox sometimes doesn't include the value stored in the table for that specific record (I hope that makes sense.)

    Is there a way to only run the query to populate the combobox when creating new records or editing and not when I am just browsing? Or am I justdoing something wrong? Any suggestions would be much appreciated.

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    When browsing, you will probably need to requery all your combo boxes in the On Current event of the form, so that they get updated each time you move to a new record.

    Just a caveat to be aware of - when you are browsing / editing, be very sure you know what happens if you modify the district and/or section number - if that is the only thing you do, then the data in the municipality and inspection site will very likely be wrong. You would have to re-select them, and the form should enforce that rule somehow.

    HTH

    John

  3. #3
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    119
    Hi John,

    Thank you so much! This worked perfectly. And thank you for the suggestion, I very much appreciate it. Have a wonderful day!

    Adrian

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

Similar Threads

  1. Replies: 2
    Last Post: 05-02-2013, 03:01 AM
  2. Combobox form display order
    By Duncan in forum Access
    Replies: 5
    Last Post: 08-23-2011, 05:17 PM
  3. Replies: 6
    Last Post: 04-27-2011, 06:12 AM
  4. Replies: 1
    Last Post: 03-24-2011, 07:09 AM
  5. Replies: 5
    Last Post: 03-30-2010, 12:53 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