Results 1 to 4 of 4
  1. #1
    phil123 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    22

    Query that populates form

    Hi all,

    So a bit a confusing one....

    I have a query which I am using to populate a form. The query uses criteria which looks up a value from a combo box on a different form. The command button on this form is then set to open the relevant form and run the query.

    I have managed to get this to work successfully in a different part of my database on a different field. I am now basically replicating the query and moving the combo box to a different field. However this doesn't seem to work. If I change the criteria in the query to [enter] and manually type in a value, this works every time and the database opens up the correct form and brings up the correct records. However, if I change this to the combo box and run, I just get a blank page with none of the boxes showing up.



    It's very confusing as I have basically copied the previous query which runs perfectly and tweaked the relevant bits of code.

    Any suggestions?

    Thanks
    Phil

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    What is the code, and what is the form name involved.
    Probably worth posting up the SQL of the Query as well.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    phil123 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    22
    So, I've just been having a bit of a play and think I've worked out the cause.

    The field I am defining using the combo box is originally entered using a series of queries. Basically I have a field to enter the department, field to enter area, and a field to enter staff names. The areas can only come under one department, and the staff members will only work in one area. Therefore, I have a query set up for data entry so that when I select one department, only the areas in that department are displayed, and so on for staff names. Hope that all made sense.

    I think the fact that this is populated by a query is causing the problem with the query I have mentioned above. I have just removed this query from the staff members drop down list and populated this directly from the source table. I have select a staff name from my combo box, ran the query, and the form has been populated as expected.

    I guess therefore my new question is whether I am able to leave the queries on these fields which filter the information down (for department, area, staff member) and also be able to do a search using my combo box to just display records which relate to each of these.

    Thanks
    Phil

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    It's called cascading (or dependent) comboboxes. Very common topic. Yes, combobox RowSource must be a query for this to work.

    Controls used to input/select criteria to filter form must be UNBOUND (unless you use right click shortcut menu or filter by form methods).
    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.

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

Similar Threads

  1. Replies: 25
    Last Post: 11-17-2023, 08:53 AM
  2. Replies: 7
    Last Post: 04-03-2017, 08:09 AM
  3. Replies: 7
    Last Post: 02-20-2017, 11:27 AM
  4. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  5. Replies: 3
    Last Post: 09-26-2009, 01:57 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