Results 1 to 2 of 2

Thread: Set the text property of a dbcombo in runtime

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    19
    I have a dbCombo box linked to a data control. Now I want to set the dbCombo's text property in runtime to one of the entries in the dbCombo list. But I don't know the listindex of that entry, I only know the text. So I simply tried to set the dbCombo.text property but that didn't work. The style of my dbCombo is set to 2 - dbcDropDownList.

    How can you set the text???

    Thanks in advance!

    Dave.

  2. #2
    New Member
    Join Date
    Oct 2000
    Location
    Abingdon, England
    Posts
    5

    Wink

    This is a utility function I use for ComboBoxes and Listboxes which either uses the set String or a ItemData element to do the search - note itemdata must be a long, but is often useful for storing such items as a key in the database

    Chris

    CODE START:::::


    Public Sub subSetObjectListPosition(ByVal vobjListObject As Object, ByVal vstrSearch As String)

    '+
    'DESCRIPTION:
    ' This subroutine searches through a list box or combo box for the string
    ' either trying to match to the itemdata field or the list field
    ' Sets the list index if the element is found
    '
    'ARGUMENTS:
    'IN
    ' vobjListObject Object : the object to search on
    ' vstrSearch String : the sought string
    'OUT
    ' None
    'BOTH
    ' None
    '-

    Dim int1 As Integer
    Dim intIndex As Integer

    intIndex = -1
    If Trim$(vstrSearch) = "" Then Exit Sub
    ' searches on either list or itemdata
    For int1 = 0 To vobjListObject.ListCount - 1
    If vobjListObject.ItemData(int1) = Trim$(vstrSearch) Or vobjListObject.List(int1) = Trim$(vstrSearch) Then
    intIndex = int1
    Exit For
    End If
    Next

    ' only change list index if necessary -
    ' this removes unnecessary calls to click events
    If intIndex <> vobjListObject.ListIndex Then _
    vobjListObject.ListIndex = intIndex

    End Sub


    CODE END:::::
    Chris Franklin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width