|
-
April 24th, 2001, 04:32 PM
#1
Simple Combo Box Control Question...
Hello, I have a combo box on my form which style has to be 2-Drop Down list. There is an instance though where i load data onto the form from a database, and I want to set the combo box whose style is 2 to a integer i grab from the database. It keeps saying since its style is two that its a read only. I cannot change the style since what I load from the DB is a control ID that the user cannot change, but I read and save out that Id from the combo box on the save/edit. Any way to set this combo box to the number I need by searching its array some how? Code would help. Thanks
Regards,
Shane
-
April 24th, 2001, 07:00 PM
#2
Re: Simple Combo Box Control Question...
Could you include some code?
I tried this:
option Explicit
private Sub Command1_Click()
me.Combo1.Text = "3"
End Sub
private Sub Form_Load()
me.Combo1.AddItem "1"
me.Combo1.AddItem "2"
me.Combo1.AddItem "3"
me.Combo1.AddItem "4"
End Sub
It worked fine for me.
This was in a new project where combo1 is style 2. Is this what you were trying to do?
thanx/good luck,
adam
thanx/good luck
-
April 24th, 2001, 08:58 PM
#3
Re: Simple Combo Box Control Question...
For a combo box with the Drop Down list style, you cannot set the text using the combo1.text = "Something". You do it using the ListIndex property. You should know the ListIndex of the item you want to display (or you can search using a for loop) then set Combo1.ListIndex to that value.
-
April 24th, 2001, 11:11 PM
#4
Re: Simple Combo Box Control Question...
Hmm okay I get the listindex, i wasn't sure how to search the combo box. What were those methods?
Thanks
-Shane
-
April 25th, 2001, 05:34 AM
#5
Re: Simple Combo Box Control Question...
Just FYI. You can set Combo1.text = "Something" as long as "Something" is in the list. This means that the item must be added to the list first. To do
combo1.additem "Something"
combo1.text = "Something" is perfectly okay.
David Paulson
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|