Results 1 to 8 of 8
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    Update Combobox List from another value

    Hi,

    I'm a beginner of Access.

    I have a form JobF. When I have selected a value in combobox Unit, I want to update the list in Machine No. I have written a query MachineNo_CriteriaUnitQ that is the RowSource to combobox for Machine No. In this query I have written a criterion:

    [Forms]![JobF]![cboUnit]



    I'm not sure if above criterion is correct. If it is correct I need something to trigger that the value in combobox Unit has changed and then update the list in combobox Machine No by running the query MachineNo_CriteriaUnitQ. I believe I need to use event AfterUpdate or something but I don't know what to write.

    I hope I have made it clear. My database is attached.
    Attached Files Attached Files

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sounds like you're trying to do this:

    http://www.baldyweb.com/CascadingCombo.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thanks,

    That's what I'm looking for.

    However, the VBA code doesn't start when I chamge value in cboPlanning. I have added a Breakpoint in the code so it seems it doesn't trigger. Do I have to switch on VBA macros somewhere in Access? I have looked in Trust Center and I believe I have turned on macros. I know how it works in Excel. But Access is new to me.

    Code:
    Private Sub cboPlanning_AfterUpdate()
        With Me
            .cboMachineNo.Value = vbNullString
            .cboMachineNo.Requery
        End With
    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Yes, either the database must be in a trusted location or you need to explicitly enable code. There would be a button under the ribbon typically.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thanks,

    Now the macro is running.

    However I don't get my 2nd combobox (cboMachineNo) to update its list when value in the 1st combobox (cboUnit) changes in form JobF. I believe I'm writing something wrong in the criterion "[Forms]![JobF]![cboUnit]" in query MachineNo_CriteriaUnitQ below. I have attached an image of the query beneath. I have also attached a cleaned database for easier trouble shoot only showing this issue.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	14.7 KB 
ID:	26094
    Attached Files Attached Files

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try changing your query to:

    SELECT MachineNoT.ID_MachineNo, MachineNoT.MachineNo
    FROM MachineNoT
    WHERE (((MachineNoT.ID_Unit)=[Forms]![JobF]![cboUnit]))
    ORDER BY MachineNoT.MachineNo;
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thanks,

    Worked great!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Limit Combobox list
    By gw2013 in forum Forms
    Replies: 21
    Last Post: 11-26-2015, 12:09 PM
  2. Change Combobox list after use it
    By TesZero in forum Programming
    Replies: 4
    Last Post: 07-22-2014, 02:14 AM
  3. Replies: 3
    Last Post: 05-10-2013, 12:37 PM
  4. Replies: 6
    Last Post: 07-28-2011, 04:07 AM
  5. How to select ComboBox list in Run time
    By sdondeti in forum Forms
    Replies: 2
    Last Post: 06-20-2011, 10:21 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