Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10

    Problem with a combo box cascade

    Hi people! I'm having some trouble when I try to update a combo box cascading. I'll simplify a bit mentioning only where the problems are.

    I have a table with 3 fields: Product, Storage and quantity. The first two are the primary key. I made a form with two combo boxes, the first one is a simple combo box with this as data origin:

    SELECT Product FROM Distribution GROUP BY Product ORDER BY Product;

    Works fine. In the second one I want to show only the storages where the selected product is, so I create the next query:

    SELECT Distribution.Storage
    FROM Distribution
    WHERE (((Distribution.Product)=[Forms]![Loans]![ProductList]));



    I put this query as the data source of the second combo box and then I added in the afterupdate event of the first combo box:

    Private Sub ProductList_AfterUpdate()

    Me.StorageList.Requery ' StorageList is the dependant combo box

    End Sub

    The problem: it only works the first time. If I choose an option the combo box is updated, but if I change what I have selected it doesn't change, I must update the entire form manually. I'm not sure if it is a programing problem or something in my access database, because I downloaded some examples of cascading combo boxes that should be working and they don't work.

    Any ideas? Oh, and thanks for your help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    What table is this being saved into?

    Try simplifying the second combobox RowSource:

    SELECT Storage FROM Distribution WHERE Product=[ProductList];

    If you want to provide your db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    Sure, no problem providing the db. Only a warning, the database names are in spanish, I translated the names for a better comprehension.
    Oh, I tried the simplified solution and nothing, in fact on the previous version of the database I was using "id"s but I remove them trying to simplify it. Anyway, a little explanation with the spanish terms:

    Query "ConsultaArmarios": the now more simplified query.
    Table "Distribucion": Producto, Armario, Cantidad (the mentioned "Distribution")
    Table "Prestamos": where the loans are saved.
    The form "Prestamos" is where the 'problem' is.

    The form is for "Prestamos", but these data come from "Distribucion". If you have any question about the db just ask it.
    PFC_2007_v3.01.zip

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    I had assumed SQL statement was in the second combobox RowSource, not reference to a query object. Cannot simplify as suggested if using a query object.

    Why does the posted query reference Form!Loans when the form is Prestamos?

    Set the RowSource to:

    SELECT Armario FROM Distribucion WHERE Producto=
    [listaProducto];
    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.

  5. #5
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    No, sorry... I changed it from spanish to english and english to spanish (I only explained with english words). My fault, I tried it with the correct names. Sometimes you try to make something more simple and you complicate more.

    The non dependant combo box use the first SQL and the dependant combo box the second one.

    The thing is making me loose my mind is why it doesn't update. I mean, if I execute the query alone it works, if I select for the first time one product from "producto" the dependant combo box is updated and show correctly the info, but if I choose another product from "producto" the dependant combo box is not updated.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Did you fix the second combobox as I suggested? It works.
    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.

  7. #7
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    Weird, it doen't work in my computer. Second combo box now have "SELECT Armario FROM Distribucion WHERE Producto=
    [listaProducto];"

    At the beggining empty: OK
    Click image for larger version. 

Name:	01.jpg 
Views:	13 
Size:	125.7 KB 
ID:	16563

    Then I choose for example "Producto2" and I can see the corresponding info in the second combo box: OK
    Click image for larger version. 

Name:	02.jpg 
Views:	13 
Size:	128.0 KB 
ID:	16564

    I choose now "Producto3" instead "Producto2", but the records didn't change, there should be another row.
    Click image for larger version. 

Name:	03.jpg 
Views:	12 
Size:	130.4 KB 
ID:	16565

    Could be something wrong or different with my Access configuration?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    You set the RowSource to SQL statement?

    I didn't change anything else and it works.

    Delete the combobox and create new one. Sometimes they corrupt.
    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.

  9. #9
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    I tried:
    - Directly in RowSource (Origen de la fila) put the SQL select:
    Click image for larger version. 

Name:	01.jpg 
Views:	12 
Size:	112.5 KB 
ID:	16566

    - Change the query to simplify as you suggested and then at RowSource call for it:
    Click image for larger version. 

Name:	02.jpg 
Views:	11 
Size:	25.5 KB 
ID:	16567 Click image for larger version. 

Name:	03.jpg 
Views:	11 
Size:	112.6 KB 
ID:	16568

    And also try all of this with the old combobox and a new one just in case. I should be able to manage this but this is beating me, it should work but it doesn't.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    The query object cannot be simplified version.

    The query object is irrelevant if the SQL is directly in the RowSource property.

    As I said, all I did was change the RowSource property.

    If you want to provide revised db, I will test again.
    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.

  11. #11
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    I think I made what you told me, still not working at least for me but maybe I have made something wrong.
    Attached Files Attached Files

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    I downloaded this latest version. Opened Prestamos form and each time I select item in Producto, the Armario list changes. Works perfect.
    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.

  13. #13
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    Crap, in my computer doesn't work... I have 2007 and you 2010, could be that?

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Should not be difference. I used to use 2007.

    I also tested this as RowSource and it also works:

    SELECT Armario FROM Distribucion WHERE Producto=Forms!Prestamos!
    [listaProducto];
    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.

  15. #15
    uny is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    10
    Nope, nothing... I'll try at work tomorrow, there is one computer with Access too but looks like it's the Access on my computer which is not working properly or is something configured different..

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cascade Combo Box - Help! Access 2013
    By alamp85 in forum Forms
    Replies: 4
    Last Post: 04-09-2013, 03:49 PM
  2. cascade combo box
    By Andyjones in forum Access
    Replies: 6
    Last Post: 04-05-2012, 04:41 PM
  3. Sub-Sub Form Cascade Combo Boxes
    By Huddle in forum Access
    Replies: 4
    Last Post: 03-22-2012, 01:42 PM
  4. 3rd Combo Box Cascade Issues
    By GAccess in forum Forms
    Replies: 12
    Last Post: 03-06-2012, 03:16 PM
  5. Combo Cascade with a twist on autofill
    By Huddle in forum Access
    Replies: 1
    Last Post: 02-29-2012, 10:18 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