Results 1 to 13 of 13
  1. #1
    samsquared is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2021
    Location
    St. Augustine, FL
    Posts
    20

    Use selected combobox item to populate listbox

    This should be a fairly easy question to answer. (I used to be quite adept at Access but since retiring have become rusty.)




    My database has two tables:


    Stocks - ID, Stock Name, Symbol
    Dividends - ID, StockID (linked to ID from the Stocks table), Pay Date, Amount


    All I want to do is to have a form with a combobox that lists the stocks I own and when I select one, it uses the Stock ID to select the appropriate rows from the Dividends table to populate a list or subform also on the form. Later I may also want it to total the amounts for the selected stock.


    What's the easiest way to do this? I have other things I'll want to do but this should get me started.


    Thanks.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Set the Row Source of the list box or the record source of the subform to something like this:
    SELECT * FROM Dividents WHERE StockID = Forms!frmYourFormName!cboYourComboName;

    Then in the AfterUpdate event of the combo requery the list box or the subform.
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Welcome to the forum...

    Since you might want to total the amounts for selected stocks, consider using main form/sub form aet up.


    Tables:

    tblStocks
    ---------
    StockID_PK - Autonumber
    StockName - Text
    StockSymbol - Text

    tblDividends
    ------------
    DividendID_PK - Autonumber
    StockID_FK Long Integer (linked to StickID_PK from the Stocks table)
    PayDate - Date/Time
    Amount - Currency



    Queries:

    qryStocks - "SELECT StockID_PK, StockName, StockSymbol FROM tblStocks ORDER BY StockName"
    qryDividends - "SELECT PayDate, Amount FROM tblDividends ORDER BY PayDate"



    Main table : frmStocks
    Record source: qryStocks
    Default View: Continuous forms


    Sub form: sfrmDividends
    Sub form control - in the main form footer
    Record source: qryDividends
    Default View: Continuous forms

    (Access may complain, but set both forms to Continuous forms view.)





    Main form/sub form linking:
    --------------------------
    Link Master Fields = StockID_PK
    Link child Field = StockID_FK

    No programming necessary!
    Select a stock in the main form, sub form is automatically updated.



    And when you decide to total the stock dividend amounts, you can use the sub form footer for the total.


    My $0.03 .....(inflation).

  4. #4
    samsquared is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2021
    Location
    St. Augustine, FL
    Posts
    20
    Thank you both for your replies. I saw Vlad's first and successfully implemented it. Steve, I have other forms I want to do so I'll adapt your approach and give it a try!

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You're very welcome, good luck with your project!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Praps is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2021
    Posts
    7

    My Praps Database

    I have a problem starting the property window, does any one know what to do when the property wikdow does not appear?

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    It usually means you have dragged the edge of the Window off the screen to the Right.

    If you hover on the right Edge of your screen you should see the Icon for dragging the window to either the Left or Right.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  8. #8
    Praps is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2021
    Posts
    7
    have tried it did nt work, thank you any way

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Can you upload a zipped copy of the database to see if it is the same on our PC's?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    Praps is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2021
    Posts
    7

    My Praps Database

    Quote Originally Posted by mike60smart View Post
    Can you upload a zipped copy of the database to see if it is the same on our PC's?
    I have tried mz databas on mz wifes computer and there the property window appears as it has always do..

  11. #11
    Praps is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2021
    Posts
    7
    I have also tried out the MS Visual Basic Tools/Options/Docking tab hint and that did not help also, thanks to everybody for your help..

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Try an MS office repair, that can fix "odd" problems?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    this thread was hijacked and nobody noticed? I suspect that will mean that the suggested links at the bottom won't be applicable because the topic is now entirely different.
    Perhaps the property sheet was placed on the view of a second monitor. Would probably have to connect the 2nd monitor to get it back or try post 4 here
    https://www.accessforums.net/showthread.php?t=72575
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-11-2021, 07:04 AM
  2. Replies: 3
    Last Post: 08-13-2020, 02:47 PM
  3. Replies: 10
    Last Post: 10-03-2018, 01:14 PM
  4. Show Checkbox when listbox item is selected
    By gammaman in forum Modules
    Replies: 5
    Last Post: 06-04-2015, 09:46 AM
  5. Replies: 1
    Last Post: 02-01-2015, 12:16 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