|
-
Mar 14th, 2006, 12:01 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] combo box problem
hi
i am trying to get some values from database to combo box
and for example my resultset is rs
and i want to put one of the resultset value in combo box
like
combo1.text=rs(0)
but what happens is when this statement is executing the execution shifting to
Private Sub combo1_Click() function
what is the problem?
-
Mar 14th, 2006, 12:06 PM
#2
Re: combo box problem
Setting the .Text property doesn't add an item to the list, or select an item that's in the list.
VB Code:
Combo1.AddItem rs(0) & ""
-
Mar 14th, 2006, 12:16 PM
#3
Thread Starter
Hyperactive Member
Re: combo box problem
i don't want to add the value to the combo box.
i just want to show the value in combo box
-
Mar 15th, 2006, 03:43 AM
#4
Thread Starter
Hyperactive Member
-
Mar 15th, 2006, 03:45 AM
#5
Fanatic Member
Re: combo box problem
to "show" and item in a combobox, it has to be a value of the combobox. In other words, you need to "add" it to your combo box...
That's the way they are designed.
-
Mar 15th, 2006, 03:45 AM
#6
Frenzied Member
Re: combo box problem
VB Code:
combo1.Text = rs.Fields(0).Value
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 15th, 2006, 05:41 AM
#7
Re: combo box problem
Sorry, i forgot about this thread.
As I previously said, setting the Text does not select a particular item, you need to set the ListIndex. The most efficient way to do this is to find the Index of a particular item by using API. Setting the ListIndex will fire the click event, but you can simply use a Flag to ignore it.:
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Const CB_FINDSTRINGEXACT = &H158
Private Sub Command1_Click()
Dim sText As String
sText = rs(0) & ""
With Combo1
.Tag = "Ignore"
.ListIndex = SendMessage(Combo1.hWnd, CB_FINDSTRINGEXACT, -1, ByVal sText)
.Tag = vbNullString
End With
End Sub
Private Sub Combo1_Click()
If Combo1.Tag = "Ignore" Then Exit Sub
Debug.Print "Click"
End Sub
-
Mar 15th, 2006, 06:02 AM
#8
Thread Starter
Hyperactive Member
Re: combo box problem
thanks bushmobile,
that's great.idea is good
it is working
thanks a lot
-
Mar 15th, 2006, 06:04 AM
#9
Re: combo box problem
Cool 
Don't forget to mark this thread resolved.
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
|