Results 1 to 10 of 10
  1. #1
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12

    Query based on ComboBox selection

    I'm trying to create a query that will run based on what is selected in the combobox. I have a main form which holds the subform with the combobox. I want a button to open the query. The query field references the combobox with [forms]![subFrmName]![cboName].



    My problem with this comes when I press the button and I get a message box titled "Enter Parameter Value" with my field reference line Forms!subFrmName!cboName with a text box underneath.

    Am I doing something wrong? I've checked the subform name and combobox name multiple times and it appears that I'm referencing them correctly.

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    pmac -

    You could try -

    [forms]![MainFormName]![subFrmName].Forms![cboName]

    All the best,

    Jim

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    try forms!mainformname.subformname!fieldname

  4. #4
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12
    Thanks, I appreciate the help. I no longer have the annoying message box pop-up demanding a value. However, now I have another issue...

    When I press the button my query pops up but it is showing other people in the database with the same combobox value when they actually have a different value. When I select another client he information is still there and correct, it is only when I press the query button that it shows different. Any suggestions?

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    can you post a sample database with sample data. Access 2003 or below if you can.

  6. #6
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12
    mhmm sorry I can't do that.

    When this query runs, other people in the database show up with the same info as what I have selected in the combobox. I want only those people who actually have that same value showing up.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I can't guess without something to work with. The SQL code at a very minimum.

  8. #8
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12
    SELECT dbo_Table1.clientID, dbo_Table1.firstName, dbo_Table1.lastName, dbo_Table2.cName, dbo_Table2.optInStatus
    FROM dbo_Table1, dbo_Table2
    WHERE (((dbo_Table2.cName)=[forms]![frmMainScreen].[fsubCDetails]![cName]) AND ((dbo_Table2.Status)=[forms]![frmMainScreen].[fsubCDetails]![Status]));

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You're not providing a linking mechanism between the two tables that's probably why you're getting multiple results. There has to be some field your two tables have in commmon or you are going to get the number of items in the first table * the number of items in the second table (without adding criteria)

    Link your two tables correctly in your query and your issue should disappear.

  10. #10
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12
    you're right, I got it now. Thank you I appreciate the help.

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

Similar Threads

  1. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  2. Populate a field based on combobox selection
    By rscott7706 in forum Access
    Replies: 5
    Last Post: 06-02-2011, 03:18 PM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  5. Replies: 0
    Last Post: 04-17-2008, 09:24 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