Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    12

    Populate a field in a subform, with a button, based on a selection in a form?

    I have a drop down box in a form to select 1 of 10 options. I would like to create a macro that when a button is pressed, the option that is selected populates a field in a continuous subform within that form.



    For example:

    In the sample picture I have attached, I would like to put a button near the drop down called "Select" and when it is clicked, it automatically populates the field "ID" in the subform, below. One caveat, is that if I select multiple choices from the drop down, it would need to populate multiple IDs in the subform, which is a continuous form.

    Any recommendations for how to approach that?


  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    well I don't see a dropdown called 'select' ; in your diagram I am looking at one labeled 'ID'

    Access2003 does not have multivalue comboboxes - I don't think - I am thinking that was added in 07 but could be wrong; but in any cases they are needed if one is willing simply to do one at a time.

    Fundamentally the record source of the subform must be a query that dynamically calls the ID combobox values using an OR statement. If building a VBA/SQL statement on the fly is out of reach for your experience - - you could consider adding several combo boxes - and then calling them all into the query record source and use query design to call each as an OR statement. This latter approach is shown in all Access text books. If you know users will never need more than say 3-5 then this latter approach is feasible.

    After each selection of the ID combobox then you trigger a query of the subform so it will reflect the new record set.

    Hope this gets you going in the direction you need.

  3. #3
    Join Date
    Dec 2010
    Posts
    12
    Thanks - I don't believe I was very clear with what I am trying to accomplish.

    I basically want to add a button that will automatically copy and paste the ID from the drop down into the ID field in the subform. The drop boxes are cascading drop boxes, and currently, once the final (ID) drop down is selected, the user has to manually copy and paste the value into the ID field in the subform. I just want to automate that with a button.

  4. #4
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    in the afterupdate event of that combobox you can push the value into another control. the syntax for a subform is:

    me.subformname.Form!subformcontrolname=me.controln ame

    but this will not work if the subform is a continuous form - it will only work if the subform is a single form.

    in a continuous subform you must 'pull' that value while in a record of the subform....so in an event in the record - such as AfterUpdate of a field that will always be entering data put in:

    me.controlname=me.parent.controlname

    hope this helps.

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

Similar Threads

  1. Populate a field based on combobox selection
    By rscott7706 in forum Access
    Replies: 5
    Last Post: 06-02-2011, 03:18 PM
  2. Replies: 2
    Last Post: 10-19-2010, 11:05 AM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 3
    Last Post: 10-05-2009, 07:22 AM
  5. Replies: 0
    Last Post: 06-23-2009, 03:01 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