Results 1 to 4 of 4
  1. #1
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156

    Using a query to fill combo-box with only results related to the selected record.

    I am still very new to all of this, and not so good with queries. I have been trying this for days, and can't get it to work.



    I have an unbound combo box on a form meant to view insurance policies. The combo box is meant to allow users to select which producer's info they want to view in a subform (multiple producers per policy). The control between the combo box and the subform works, but I can't get the combo box to list only the producers that belong to the policy being displayed; it either just lists all the dummy producers from the table, or (as of my latest attempt) it gives me an "Enter Parameter Value" popup.

    Here's what I'm trying right now:
    Code:
    SELECT tblPolProd.PolNum, tblPolProd.EntID, tblPolProd.PolPPosition
    FROM tblPolProd
    WHERE (((tblPolProd.PolNum)=[frmPolicy3rd].[ctlPolNum]))
    ORDER BY tblPolProd.PolPPosition;
    The "WHERE" is when the policy number viewed on the form matches the policy number associated with that producer.

    I've tried switching the order in the "WHERE" as well, and it still keeps giving me the "Enter Parameter Value" popup asking for "frmPolicy3rd.ctlPolNum" (that's the policy view form and the control that displays the policy number).

    Where am I going wrong?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Use the BUILDER, when you have to reference form objects in a query. (The magic wand icon with elipsis) That way there wont be typos.

    You have to reference the WHOLE path of the form object.: forms!frmPolicy3rd!ctlPolNum

  3. #3
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156
    You're going to laugh. I had found another guide to try, and it showed the form path like that, I used it, and now it filters correctly!

    But it shows each result TWICE. Why would it do that?

    This project is going to drive me to drinking.

  4. #4
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156
    Nevermind! Figured it out.

    It just had an extra chromosome...

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

Similar Threads

  1. Replies: 8
    Last Post: 06-26-2014, 08:52 AM
  2. Replies: 9
    Last Post: 08-16-2013, 01:49 AM
  3. Replies: 3
    Last Post: 10-13-2011, 04:42 PM
  4. Replies: 2
    Last Post: 05-11-2011, 02:58 PM
  5. Auto fill field upon New Record selected
    By NOTLguy in forum Programming
    Replies: 27
    Last Post: 12-05-2010, 05:12 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