Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Cascading Combo Box

    My query for displaying the available "batches" in a "Project" isn't working and I can't seem to figure out why.

    I have an after update event, Following the tutorial here:

    http://www.blueclaw-db.com/access_ev...fterupdate.htm

    Code:
    Private Sub Project_Name_AfterUpdate()
        Forms![Doc_CreatorF]![Project_Name].Requery
    End Sub
    I don't know how to just test that the form is updating though.

    The criteria in the "Project_Name" field in the query is:



    Code:
    [Forms]![Doc_CreatorF]![Project_Name]
    So from what I understand the results of this query should update when I select from the "Project_Name" combo box.

    The second combo box uses the query to display results to pick from. But the query will never generate results.

    Any ideas how I can troubleshoot this or do something different?

    Thanks in advance. Andy.

    Additionally - The first combo box is "Remembering the value to use later" not storing it.

    All form names and references to combo boxes are correct. (I've started from scratch a few times and double checked).

    Any other information that might be useful feel free to ask.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    lots of info, but can't see how you are putting it together - for example

    Code:
    Private Sub Project_Name_AfterUpdate()
        Forms![Doc_CreatorF]![Project_Name].Requery
    End Sub
    is this requerying the project_name control in the current form a different one? - and if the current one, why are you requerying a control you have just updated?


    Suggest start again and explain what you are trying to do and not what you are doing - as a minimum, include names of forms and relevant controls rather than using terms like 'the form'. Include rowsources for comboboxes and if that rowsource is a query, the sql to the query

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I want a combo box which returns values depending on the selection in the first combo box. All of this is on one form. (any reference to form is "Doc_CreatorF") I select a value in the first combo box and in the second I want it to display everything under it.

    EG. If project 1 was selected the second combo box should show all "batches" relating to project 1. (same throughout).

    The reason the query needs to run again after update is because its dependant on the result from the combo box. So when the box is changed/updated the query needs to run again to pull records/values for the second combo box.

    assuming the update works (I don't know how to test) the problem lies in the query. Its never returning any values.

    here is the SQL
    Code:
    SELECT ProjectT.Job_Type, BatchT.Batch_Number
    FROM SiteT INNER JOIN (ProjectT INNER JOIN (BatchT INNER JOIN JobT ON BatchT.[Batch ID] = JobT.Batch_ID) ON ProjectT.Project_ID = BatchT.Project_ID) ON SiteT.Site_ID = JobT.Site_ID
    WHERE (((ProjectT.Job_Type)=[Forms]![Doc_CreatorF]![Project_Name]));
    If you look at the tutorial I linked it shows the requery there. I have tried to copy the tutorial.

    cheers, Andy.

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Hm, this isn't how I have done cascading combo boxes before.

    So if (cboProj) Project 1/2/3 needs to show batches1/2/3 in cboBatches let's call it (representing any amount of batches) then they have to be related in some table.

    Then in your query behind cboBatches you want to have it contain fields Projects and Batches.
    The criteria for projects is going to be Where [Forms]![Doc_CreatorF]![cboProj]
    Click image for larger version. 

Name:	llll.PNG 
Views:	17 
Size:	6.5 KB 
ID:	21561
    Just how I normally do casc. cbos...

  5. #5
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I'll leave Nick404 to follow through, you haven't provided what I asked for so can't really help

  6. #6
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    Quote Originally Posted by nick404 View Post
    Hm, this isn't how I have done cascading combo boxes before.

    So if (cboProj) Project 1/2/3 needs to show batches1/2/3 in cboBatches let's call it (representing any amount of batches) then they have to be related in some table.

    Then in your query behind cboBatches you want to have it contain fields Projects and Batches.
    The criteria for projects is going to be Where [Forms]![Doc_CreatorF]![cboProj]
    Click image for larger version. 

Name:	llll.PNG 
Views:	17 
Size:	6.5 KB 
ID:	21561
    Just how I normally do casc. cbos...
    In my experience, that is the best way to do cascading combo boxes in Access. Value from combo box 1 feeds into query, query determines values for combo box 2. The requery command helps if you update the value in combo box 1, but it takes both pieces to make the puzzle complete.

  7. #7
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    The requery command helps if you update the value in combo box 1, but it takes both pieces to make the puzzle complete.
    Yes, I forgot the requery portion. Behind the first combo box in the AfterUpdate requery.

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Quote Originally Posted by Ajax View Post
    I'll leave Nick404 to follow through, you haven't provided what I asked for so can't really help
    What did I not include that you asked for? I appreciate if that's how you feel it can be frustrating, but apply that advice to yourself. Its not just me that needs to be more clear.

    cheers nick and kagoodwin, ill take a look at the suggestions.

  9. #9
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I asked

    is this requerying the project_name control in the current form a different one?
    you answered - 'All of this is on one form' OK. I can work that out

    I asked
    - and if the current one, why are you requerying a control you have just updated?
    no answer

    I asked
    as a minimum, include names of forms and relevant controls rather than using terms like 'the form'. Include rowsources for comboboxes and if that rowsource is a query, the sql to the query
    you replied
    select a value in the first combo box and in the second I want it to display everything under it. ....The reason the query needs to run again after update is because its dependant on the result from the combo box. So when the box is changed/updated the query needs to run again to pull records/values for the second combo box....the problem lies in the query.
    For all I know the 'second' combobox rowsource has not been set or is referring to a different query, your 'requery' code appears to be requerying the wrong control (but without knowing why you are requerying that particular control, who knows?) You say the problem is with the query - why would you think that?

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    the "Project_Name" combo box needs to trigger the requery after update so the query has a value to work with. The query is dependant on the value from the "Project Name" combo box.

    This could be where the problem lies.

    Alternately, It might be the query itself. The reason I say this is because I can never get it to generate results (when I manually run it in design view.).

    So either the reference from "project name" isn't there for the query to work. Or the query is wrong.

    anything to do with combo box two is irrelevant at this stage, It cant display results/records that don't exist.

    you say I'm requerying the wrong control (or possibly). Ill look into this; to be honest I don't understand this properly.

    also I just noticed I linked the wrong tutorial. Which only added to the confusion,

    http://www.blueclaw-db.com/comboboxl...pdown_list.htm
    <this is the right one.

    Ill have a look into the requery event.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  12. #12
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Thank you. Ill get to this when I get the chance.

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

Similar Threads

  1. Cascading Combo Box help
    By kspabo in forum Access
    Replies: 11
    Last Post: 06-27-2014, 01:00 PM
  2. Replies: 1
    Last Post: 02-27-2014, 03:43 PM
  3. Cascading Combo Box Help
    By euphoricdrop in forum Forms
    Replies: 3
    Last Post: 04-12-2011, 05:35 PM
  4. cascading combo
    By rexb in forum Forms
    Replies: 9
    Last Post: 10-26-2009, 04:10 PM
  5. Cascading Combo Box
    By nywi6100 in forum Forms
    Replies: 0
    Last Post: 10-23-2006, 01:45 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