Determine selected item in ComboBox

TravelingCat

Registered User.
Local time
Today, 20:05
Joined
Feb 22, 2010
Messages
42
Hello
I have a combobox with Forum names in it. When user selects a forum from the list, i need to determine which one is it, go to tblForums (or form) and pull out the content of the field "forumParticipants" (of course, participants of the forum that was selected by user).
The problem is i have no idea how to do that. So far i have the index of selected item, but i don't really know what's next..
Any help will be appreciated
 
Hello
I have a combobox with Forum names in it. When user selects a forum from the list, i need to determine which one is it, go to tblForums (or form) and pull out the content of the field "forumParticipants" (of course, participants of the forum that was selected by user).
The problem is i have no idea how to do that. So far i have the index of selected item, but i don't really know what's next..
Any help will be appreciated


With a combo box you would have the row source be the Forum_ID (Priamry key) and the Forum Name from the Forums table. You set the bound column property for the combo box to the column for the Forum ID, By doing this the value return from the combo box will be the primary key for the selected record.

To get the value from the combo box you can use just a reference to the combo box liek this:

= Me.cboYourControlName

If it we me, I would use a sub form to display the records from the table forumParticipants on the same form below the combo box. I would set the master linking field property to the combo box.

Hope this helps ...
 
Hi, thank you for your reply
Actually i had this column unbound, cause when i make it bound (Control Source = forumNum) it becomes "locked", the list drops down but doesn't allow me to pick anything. So i can't even run debug and check the code. Do you have any idea why the combobox becomes "locked"? (of course it's locked property is set to No)
 
Hi, thank you for your reply
Actually i had this column unbound, cause when i make it bound (Control Source = forumNum) it becomes "locked", the list drops down but doesn't allow me to pick anything. So i can't even run debug and check the code. Do you have any idea why the combobox becomes "locked"? (of course it's locked property is set to No)

I was not referring to the control source. I was referring to the property named Bound Column. For a combo box there is a property named Bound Column that identifies the column in the Row Source property's setting.

With a combo box you would have the row source be the Forum_ID (Priamry key) and the Forum Name from the Forums table. You set the bound column property for the combo box to the column for the Forum ID, By doing this the value return from the combo box will be the primary key for the selected record.

I did not mention the control source property since I assume it was an unbound control.

Do you have any idea why the combobox becomes "locked"? (of course it's locked property is set to No)
At the form level, is the Allow Edits property set to Yes.
 
All the "alows" are set to Yes
The bound control in the combobox was set to 0, but when i changed to 1 it didn't help either.
Any more suggestions?... :(
 
You need write a function and do following thing to find the index of any specific element within the combo box

0. Introduce a counter =0
1. Iterate through the combo box from first element too the last
2. Compare the value of every item with that value whose index you want to know
3. Add 1 to increase the value of counter if not compared and loop again

wherever the condition match the criteria stop the loop and use the counter value
that's it.

Regards
 
Hi Arain,
thanks for replying but this thread is 3 years old
I no longer work with access
Maybe it will help someone else;)
 

Users who are viewing this thread

Back
Top Bottom