Results 1 to 11 of 11
  1. #1
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8

    Question Populate the selected data from sub form to drop down list

    How can I populate the selected data from sub form to the drop down list? My sub form has 5 columns and only column 1 data of selected record will be populated in the drop down list. How can I do that and what VBA code I should use? Thank you.


    Albert

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Why do you need this? Is the combobox bound or unbound?
    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
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8
    Quote Originally Posted by June7 View Post
    Why do you need this? Is the combobox bound or unbound?
    The combobox is unbound. Indeed, the users prefer to select the item (one item at a time) in the sub form rather than populate the value by using SQL and populate in the combobox (I populate the values on combobox by using SQL already). Just wonder if i can do both. Thanks.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    I still don't understand what is going on. Why does this one value need to go to an unbound combobox? I am really confused by your second post. What is meant by 'users prefer to select the item (one item at a time) in the sub form rather than populate the value by using SQL'. How would users use SQL? What are the 'both' you refer to? If you have something working what needs to be different?
    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
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8

    Populate the selected data from sub form to drop down list

    Currently, we have a sub form in order to display the borrowed items and the combobox for the librarian to select the item and click the return button to check in the item. We populate the borrowed item # on the combobox by using SQL.
    Now, user would like to select the item on the sub form and populate the item # in the combobox automatically.

    That's what I need. Please help.
    Albert

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Still confused. If the item is in the subform why is it not already in the combobobx RowSource? Guess I have to see to understand if you want to provide the project. What is nature of this database? Sounds like a lending library. Have you checked out the MS Lending Library template?
    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
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8

    Smile Populate the selected data from sub form to drop down list

    Yes, it is an Access database for library, I have attached the screen shot for your reference.
    We populate the checked out items' call number by using SQL in combobox already. However, users do not want to pick it from the combobox, they want to select the item on the sub form, which is the checked out record, and populate the call number on the combobox automatically. That's what I need your help.


    Albert

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Oh, you don't need to add to the combobox RowSource, you want to set the Value of the combobox.

    Is the combobox unbound? Is it multi-column. Show the combobox RowSource.

    You could use the Click event of the Subform or its Detail section or of a particular control of the subform. Then possibly: Forms!mainformname.comboboxname = Me!CallNumber
    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
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8

    Smile Populate the selected data from sub form to drop down list

    I got it. Thanks everyone. I used the following code for that.

    Code:
    Private Sub YourFieldNameHere_Click()
    
    ' change the Field name and Combobox name accordingly
    Me.Parent.YourComboBoxNameHere = Me.YourFieldNameHere
    
    End Sub

  10. #10
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Just a curious question: why do you need the combobox if you just want to give the users an option to 'return' the book? You could do it just as easily directly for the selected row from the subform!

  11. #11
    albert_leung is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    8

    Populate the selected data from sub form to drop down list

    At the beginning, I thought the user select the call # in the combobox instead of selecting the call # from the sub-form. I have SQL to populate the call # as same as the sub form. Now, the user want to pick the call # from the sub form instead.
    Albert

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

Similar Threads

  1. Replies: 6
    Last Post: 07-10-2011, 05:33 PM
  2. Replies: 4
    Last Post: 06-16-2011, 09:30 PM
  3. Replies: 12
    Last Post: 04-18-2011, 08:52 AM
  4. Data Entry Form: Retain Selected List Box Value
    By William McKinley in forum Forms
    Replies: 1
    Last Post: 11-05-2010, 10:14 AM
  5. Replies: 1
    Last Post: 03-15-2010, 02:52 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