Results 1 to 9 of 9
  1. #1
    combine21 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    31

    combo box


    I have a combo box in a form and I want my selection to be stored in two seperate tables. Is there some coding I need in the After Update to do this? Or is there a simpler way?
    Please help...thanks

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Absolutely you need in the After Update to do this.
    if you don't know what code you need, please provide the name of the combo box, two tables' names, field names and the primary keys, and the object name in you form holding the primary key.

  3. #3
    combine21 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    31
    My combo box in the form is Combo18. My tables are tbl_study_group and the field in this table is Study. The other table is tbl_study_names and the field in this table is Study names. There is no primary keys in either table. Does that create a problem?

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Not enough information. what is in you combo18? study or study name or other information? and what do you want to update to the two tables?

    (suppose tbl_study_names has two fields: study and studyName, if only one field, that's a problem.)

  5. #5
    combine21 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    31
    Combo18 is from tbl_study_names. Tbl_study_groups_has more data than just names. I want to be able for the combo box to store a new name in tbl_study_names if a new one is typed in thats not already in the dropdown. And i want to store the record in tbl_study_groups as well. Tbl_study_names only has the fields Study Name and Current (checkbox). In the two tables, Study in tbl_study_group and Study Names in tbl_study_names are equal. Should I make an autonumber field to set a primary key?

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Should I make an autonumber field to set a primary key?
    many people suggest that, but I don't mind. actual I don't like autonumber because it means nothing.

    for tbl_study_names, I understand what you want to do: add new record if not exist. please see following code.

    for tbl_study_group, I am not sure. do you still mean just simply add a new record? if so, just copy following code and modify accordingly


    private sub combo18_before_update()

    dim i as integer
    i=dcount("*","tbl_study_names","[study name]='" & combo18 & "'")
    if i=0 then
    currentdb.execute "insert into tbl_study_names ([study name]) select '" & combo18 & "'"
    end if
    end sub

  7. #7
    combine21 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    31
    Thank you so much. I worked like I was hoping.

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    May I mark this issue as solved?

  9. #9
    combine21 is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    31
    Yes it's been resolved

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

Similar Threads

  1. Combo box dependant on another combo box
    By nianko in forum Forms
    Replies: 15
    Last Post: 08-20-2010, 07:06 AM
  2. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  3. Replies: 3
    Last Post: 02-26-2009, 10:17 AM
  4. Replies: 0
    Last Post: 08-17-2008, 12:19 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