Results 1 to 7 of 7

Thread: Data Combo Box

  1. #1
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 01
    Location
    Colorado
    Posts
    329

    Question

    I am tring to use a data combo box to look up a record in my data base. I have it bound to a field "CustomerName" in my data enviroment but when I select on of the customers names I can't get it to bring up the rest of the fields in the Record that are linked the same data enviroment and command. The source of my datadase is Microsoft Jet OLE DB 4.0 Provider. Im sure Its just a code issue but, I not sure .

    If anyone can help I would greatly appreciate it.

    Thanks..

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 00
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Make sure the Rowsource and Listfield (maybe RowMember as well) are set right to put the data in the drop down list. Depending on what you are doing you probably don't need to set the Datasource, member and field props. Then the click event for the dcbo should look like this:
    Code:
    Private DataCombo1_Click(Area as integer)
       If area=2 then
         adodc1.recordset.bookmark=datacombo1.selecteditem
       End if
    End Sub
    This code assumes there is an ado control named adodc1 with the info in it.

  3. #3
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 01
    Location
    Colorado
    Posts
    329

    About your code?

    I modified your code to :

    Private Sub DataCombo1_Click(Area As Integer)
    If Area = 2 Then
    DataEnvironment1.rsCommand1.Bookmark = DataCombo1.SelectedItem
    End If
    End Sub


    My DataCombo was working in the aspect that it listed the contents of "CustomerName" and when I selected a different CustomerName My TextBox "CustomerName" changed But the rest of the information on my form didn't update.

    This is how I am set up:

    txtFields(0)

    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = CustomerName

    txtFields(1)

    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = Address

    txtFields(2)

    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = City

    txtFields(3)

    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = State

    txtFields(4)

    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = Zip

    DataCombo1

    BoundColumn = CustomerName
    DataSource = DataEnviroment1
    DataMember = Command1
    DataField = CustomerName
    ListField = CustomerName
    RowSource = DataEnviroment1
    RowMember = Command1

    I am running SP4
    If you have any other suggestions that might help I would appreciate it...

    Thanks,
    Jason

  4. #4
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 01
    Location
    Colorado
    Posts
    329

    Smile I got it to work

    My DataEnviroment Connetion is liked to a MS Access database. I went into Access and created a Query for my table which is Command1 then I went into my DataEnviroment and added a new Command "Command3" and set database object to "View" and object Name to "name of my Query" and made no relation. Then I changed my DataComboBox settings to ->>



    BoundColumn = CustomerName
    DataSource = DataEnviroment1
    DataMember = Command3
    DataField = CustomerName
    ListField = CustomerName
    RowSource = DataEnviroment1
    RowMember = Command1

    and the Code that Edneeis Provided me with I changed it to --->>>

    Private Sub DataCombo1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    DataEnvironment1.rsCommand1.Bookmark = DataCombo1.SelectedItem
    End Sub


    --->>>This works very well<<<---

    Now that I am fat and happy. I now need to find out how to get the list to sort in alpabetical order ` it never ends but, it's fun.....

    Thankyou Edneeis for helping making this progress..

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 00
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Here is the scoop (depending on what you are doing), if you set the datacombo data source,member, and field props then sometimes when you select a new record via the combo it just inserts the value into the field assigned in the datafield prop. So just a warning if you run into any problems if not then nevermind.

  6. #6
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 01
    Location
    Colorado
    Posts
    329
    After my last post I started to see the problem you just described. I had to drop the settings Data Sorce, Member, and Field .

    Do you know how I can have the list in the bound column to sort in alpabetical order ?

    Thanks again for your help..

    Jason

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 00
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Unfortunatly you can't sort or filter the records in the combo unless you change the actual recordset its bound to and rebind it. So you could set up you data environment command to sort and then bind it.

Posting Permissions

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