Unanswered: Stupid Newbie: How do I populate a combobox with values from a table?
I'm developing a DB with Access 2000 and VBA, and was hoping you could help me. Right now, the problem I'm stuck on is this: I've got a group of 3 option buttons on one form. The option buttons correspond to fields on a table I've made.
Anyways, when the first form exits, I open a new form, which contains a combobox. I would like to have that combobox populated with the corresponding data from my table. For example, if I had option 1 selected on the first form, I'd like the second form's combobox to contain all the data in field 1 from my table.
It doesn't sound that complicated to me, but I can't figure it out for the life of me.
the combobox has a property called boundcolumn. It is a value that corresponds to the column displayed in the combo box eg 1 for the first column, 2 for the second, etc. i would set this to the corresponding number when you open the form for example in the form open code i would put something like
" Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "formname" ' Open new table
DoCmd.OpenForm stDocName, , , stLinkCriteria
if option1.value = true then form_formname.combobox.boundcolumn = 1
if option2.value = true then form_formname.combobox.boundcolumn = 2
if option3.value = true then form_formname.combobox.boundcolumn = 3
docmd.close ' close the first form "
where formname is the new form youve opened and combobox is the name of the combobox you wish to populate. Is that helpful, if not let me know ill try and help more
In the same way and to complete my response :
if option1.value = true then form_formname.combobox.sourcecontrol = Field1
if option2.value = true then form_formname.combobox.sourcecontrol= Field2
or with the rowsource use a query selecting Field1 or Field2 or ....
> or with the rowsource use a query selecting Field1 or Field2 or ....
This is what I was trying to do, and putting it in the form_load method. Problem is, form_load doesn't get called (is it only when it is first called, or what?), and like I said, whenever I put any code in form_open, the program chokes.