none
Save user selection from combo boxes RRS feed

  • Question

  • I've been away from programming for about 10 years and I'm doing a small volunteer project in Access 2010 for a Nature Center.

    I have a form with 2 combo boxes populated from queries... 1 has "Participant" (Name & ID) and the other has "Event" (Name & ID).  I have a destination table with 4 columns (ID(Auto), ParticipantID(Number), EventID(Number) and DateAdded(Now())).

    I would like to take the ID values from each combo boxes data and add a new row to my "ParticipantToEvent" table.

    What is the most expedient method to do this?

    NOTE:

    I have used as many bound controls as possible as this app will live long after I have left and needs to stay as simple as possible for future people to maintain.

    Thanks in advance for your kind help.

    Phill


    SquireDude

    Tuesday, August 15, 2017 11:36 PM

All replies

  • Hi Phil,

    The most expedient method would be to bind the comboboxes; but if you're using unbound comboboxes, then you may need to use an APPEND query to push the selections to the table. For example:

    strSQL = "INSERT INTO ParticipantToEvent (ParticipantID, EventID) VALUES (" & Me.Combo1 & "," & Me.Combo2 & ")"

    CurrentDb.Execute strSQL, dbFailOnError

    Please note the above assumes DateAdded has a Default Value set to Now().

    Hope it helps...

    Wednesday, August 16, 2017 12:23 AM
  • Thanks for the response.  Based upon your answer I have a questions for you....

    You noted that the combo box selection result could be bound.  How would I make the combo boxes Bound to my destination table?

    Sorry if this sound kind of basic but as I noted I understand the concept but 10 years of retirement has not made me a better programmer! :-) 

    Thanks

    Phill


    SquireDude

    Wednesday, August 16, 2017 2:14 PM
  • Hi Phill,

    I was saying binding the combobox to the table would automatically save the data, but to do so, you'll need to bind the form to the same table and bind the combo to the field.

    Hope it makes sense...

    Wednesday, August 16, 2017 2:45 PM
  • Hello Phill,

    Have your issue been resolved? If your issue has been fixed, i suggest you mark helpful post as answer to close this thread. If you have any new issues, please post new thread.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 18, 2017 9:02 AM
    Moderator