Results 1 to 9 of 9
  1. #1
    dgunkel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5

    Help With Cascading Dropdown/Combo Box Code

    Hey Everyone,



    I'm working on creating a form for work. It's a really simple database that is being used to show a "dashboard view" of some client revenue information. I'm having trouble programming the "after update" event for my drop down list. I want to be able to select a client name from the drop down box and then have the relevant revenue information show up in the combo box below.

    I'm not great in Access, help would be appreciated.

    Thanks

    ITPA.zip

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Can't read access 2007+ if you can convert it to 2003 I'll take a look.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Concatenate variables into sql string. Reference to Me!Company is a variable.

    .RowSource = "SELECT Revenue_Amount " & _
    "FROM Client_Revenue " & _
    "WHERE Client_Name = '" & Me!Company & "'"

    Company is not included in the form's RecordSource. There is no field or control by that name, perhaps should be Client_List?

    The control named cbo_Revenue is a listbox, not combobox, better name would be lst_Revenue. You have the listbox set for 5 columns, with the first 0 width but the code retrieves only 1 field in the listbox RowSource.

    Try these edits:

    Set Client_List combobox BoundColumn to 1.

    Set cbo_Revenue RowSource to:
    SELECT * FROM Client_Revenue WHERE Client_Name=[Client_List];

    Change code to:
    Option Compare Database
    Option Explicit
    Private Sub Client_List_AfterUpdate()
    Me.cbo_Revenue.Requery
    End Sub
    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.

  4. #4
    dgunkel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5
    Hi,

    I updated my code to concatenate the variables in sql string. Not something I'm familiar with clearly.

    Also you are correct about Company that was a typo on my part. It was indeed suppost to be Client_List. I also updated the listbox name to more accurately reflect the type of control. Initially I was planning on pullin in all 5 columns in the Revenue table for the selected client, but as I started to have issues I was just trying to get one column to populate. Could you help me to populate all 5? Any chance you could upload a working version of the database?

    Here's the updated version:

    ITPA Updated.zip

  5. #5
    dgunkel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5
    ITPA 2003.mdb

    I converted it to Access 2003 if you want to have a look:

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Perhaps I was editing my post as you created yours. Review again. Did you try the edits I suggested?
    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
    dgunkel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5
    Yeah sorry I updated the attachedment above a few times in the last few minutes. I did incorporate the edits you suggested, however it's still not working. Here is the latest version:

    Just saw your post up there, forums aren't so good for real time stuff. Let me try those edits.

    REALLY appreciate your help, I'm a bit in over my head.

    ITPA Latest.zip

  8. #8
    dgunkel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    5
    I updated the Database with your edited suggestions, and it's working! Thanks a bunch. What exactly do these lines of code do?

    Option Compare Database
    Option Explicit

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Not sure about the first. Just know all my code modules are generated with it. http://support.microsoft.com/kb/98227

    The second aids in debugging errors. http://www.fmsinc.com/free/NewTips/V...ion/index.html
    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. VBA Code Dropdown
    By hawzmolly in forum Access
    Replies: 3
    Last Post: 07-03-2012, 09:01 AM
  2. Combo box dropdown style
    By desk4tbc in forum Programming
    Replies: 4
    Last Post: 10-05-2011, 05:55 PM
  3. Replies: 8
    Last Post: 03-14-2011, 09:45 AM
  4. Combo Box dropdown to size width of columns
    By noweyout in forum Forms
    Replies: 1
    Last Post: 02-18-2011, 05:56 AM
  5. Minimizing combo dropdown on click
    By DanW in forum Forms
    Replies: 2
    Last Post: 11-18-2009, 03:33 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