I've been been combing this forum for a solution since Friday. I was hoping to scavenge some useful bits of code that I could twist to my own evil ends, but I think I've hit a dead end. There are several posts that sort of touch on what I'm trying to do, but most of the scenarios that have been addressed are a bit more complicated than my little conundrum, and I don't seem to be able to whittle them down.
I have a table that I need to append. The table, which is called Academy Awards x, has the following columns: ID (which is an Autonumber), Ceremony, Award Year, Award Category, and Title. Because of the nature of the table, it is possible (likely, actually) that one Title will appear on multiple rows, as the title will have multiple Award Categories. I am attaching a screencap named TableAcademyX for clarity.
To Append this table, I've created a form called xAppendAcademy. The form has three unbound TextBoxes: txtTitle, txtCeremony, and txtYear, which correspond to the columns on my table. The person using the form will enter the appropriate information into those fields. I managed to successfully create an Append Query which adds those fields to my table. (QueryAppend.jpg attached)
So far, so good, except that this is where I get stuck.
I need some way to Append multiple Award Categories to the table. It seems like the best way to do this is to use a multiselect ListBox, so I placed one called ListAwardCategory on the form. It's an unbound box with the various Award Categories in it. Right now, I have the multiselect property set to "Simple," so my user can select multiple award categories.
I thought at first I could point the Award Category field in the Append query at this ListBox, but that was a no-go. I then had the idea that I could create a hidden TextBox, make the Control Source property "=ListAwardCategory.column(0)", and point the Append query at that. This works, but only if there's is not more than one item selected in the ListBox (which kind of defeats the purpose).
I think I need some kind of a code solution, which is supported by most of the postings I've found here that relate to this issue.
I could use a Command Button, with an On Click event that runs some kind of a loop. I need something that says take each item in ListAwardCategory (me.ListAwardCategory.ItemsSelected?), insert it into table Academy Awards x, and fill the Ceremony, Award Year, and Title fields from the appropriate TextBox on the xAppendAcademy form. And then go back and do it again until all the items in ListAwardCategory have been filled.
This is where I'm at. I think I'm close, but lack the nuts-and-bolts knowledge to make this thing work.
I'm not really close, am I?
I have a table that I need to append. The table, which is called Academy Awards x, has the following columns: ID (which is an Autonumber), Ceremony, Award Year, Award Category, and Title. Because of the nature of the table, it is possible (likely, actually) that one Title will appear on multiple rows, as the title will have multiple Award Categories. I am attaching a screencap named TableAcademyX for clarity.
To Append this table, I've created a form called xAppendAcademy. The form has three unbound TextBoxes: txtTitle, txtCeremony, and txtYear, which correspond to the columns on my table. The person using the form will enter the appropriate information into those fields. I managed to successfully create an Append Query which adds those fields to my table. (QueryAppend.jpg attached)
So far, so good, except that this is where I get stuck.
I need some way to Append multiple Award Categories to the table. It seems like the best way to do this is to use a multiselect ListBox, so I placed one called ListAwardCategory on the form. It's an unbound box with the various Award Categories in it. Right now, I have the multiselect property set to "Simple," so my user can select multiple award categories.
I thought at first I could point the Award Category field in the Append query at this ListBox, but that was a no-go. I then had the idea that I could create a hidden TextBox, make the Control Source property "=ListAwardCategory.column(0)", and point the Append query at that. This works, but only if there's is not more than one item selected in the ListBox (which kind of defeats the purpose).
I think I need some kind of a code solution, which is supported by most of the postings I've found here that relate to this issue.
I could use a Command Button, with an On Click event that runs some kind of a loop. I need something that says take each item in ListAwardCategory (me.ListAwardCategory.ItemsSelected?), insert it into table Academy Awards x, and fill the Ceremony, Award Year, and Title fields from the appropriate TextBox on the xAppendAcademy form. And then go back and do it again until all the items in ListAwardCategory have been filled.
This is where I'm at. I think I'm close, but lack the nuts-and-bolts knowledge to make this thing work.
I'm not really close, am I?