Results 1 to 5 of 5
  1. #1
    Rustin788 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Posts
    47

    Post Cascading Combos & DLookUp

    Hey,

    I'm run into a few issues when creating a form for our locations to input data.



    • The first issue I am having is finding a way for a text box using a DLookUp to record that information in the data table. I have it set so that the supervisor can add in the Employee ID and then the employees Name shows up in the Employee field after it looks into the Employee List and matched the ID with the Name. I'm trying to get that name in the data table.
    • The second issue I'm having is getting Cascading Combo boxes to work. I can get them to populate the first time, but if the initial combo box is changed, the second one does not up data. In After Update, I have tried to Requery, and setting the RowSource = to the Row Source. The data is a very simple table that has the Location (4 total) and a piece of Equipment at that location.


    Thanks for any help, I think I've done just about every tutorial I could find for the Cascading Combo boxes and they never want to requery for me.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    the 2nd combo should look at the 1st combo as criteria
    combo2 query: select city from table where [state]=forms!fMyForm!cboState

    then on the form when user picks a state from combo1, you must refresh combo2 (the cities):
    Code:
    sub cboState_AfterUpdate()
    cboCity.requery
    end sub

    dlookup format is:
    =dlookup("[field2return]","query/table", sWhereClause)

    the sWhereClause can be:
    "[City]='" & cboCity & "'"

  3. #3
    Rustin788 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Posts
    47
    Hey, Thanks for the quick response. Here are some screen shots of my combo boxes and the Code. It still works fine on the initial dropdown but it doesn't change if it is switched.

    Click image for larger version. 

Name:	combobox.jpg 
Views:	15 
Size:	160.7 KB 
ID:	45243

    Here is what I have for my DLookUp. It grabs the information fine, I'm still not how to get that information to save with the rest of the form in the table.

    Code:
    =DLookUp("[Employee_Name]","[EmployeeListTbl]","[Employee_Code]= '" & [Forms]![Copy of Audit Entry Form]![cbxEmployeeCode] & "'")
    Thanks!

    (Note, I'm doing everything on a test form right so ignore some of the naming schemes, they aren't permanent)

  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,652
    Can you attach your test db here?

    You would typically not save name in related tables, just the code. What if the name changed in the future? Your old records would have the wrong name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Rustin788 View Post
    .... The second issue I'm having is getting Cascading Combo boxes to work. I can get them to populate the first time, but if the initial combo box is changed, the second one does not up data. In After Update, I have tried to Requery, and setting the RowSource = to the Row Source. The data is a very simple table that has the Location (4 total) and a piece of Equipment at that location.......
    Here is a demo for Cascading Combo boxes (and list boxes). Make a few selections, then go back and change an earlier combo box. Look at the VBA code in the after update events...
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 17
    Last Post: 07-29-2019, 04:24 AM
  2. Replies: 8
    Last Post: 06-03-2015, 02:11 AM
  3. Replies: 3
    Last Post: 09-13-2013, 01:45 AM
  4. Cascading combos in a form
    By jessaw in forum Forms
    Replies: 1
    Last Post: 11-02-2012, 02:13 AM
  5. Cascading combos issue
    By Andyjones in forum Programming
    Replies: 5
    Last Post: 04-14-2012, 11:09 AM

Tags for this Thread

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