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
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
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.
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?
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.)
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?
many people suggest that, but I don't mind. actual I don't like autonumber because it means nothing.Should I make an autonumber field to set a primary key?
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
Thank you so much. I worked like I was hoping.
May I mark this issue as solved?
Yes it's been resolved