Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2003
    Posts
    20

    Unanswered: How can i fill a text box with the relative data from a combo.

    The query for the combo returns:
    Err_id err_name
    01 qaz
    02 qwe
    03 ccn

    the combo got the err_name data.
    how can I fill the text box with the err_id, e.g when I hit “qaz” the “01” to fill the text box

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    it is all in the which column is the bound column in properties/data of the combobox

    also you can identify any value in the row of the combobox by calling out the index number of the column

    MsgBox Combo27.Column(1)


    will display the value of the SECOND column

    the index starts with (0) not 1

  3. #3
    Join Date
    Jun 2003
    Posts
    20
    nothing happens the text box remain empty or contains the combo’s data but never the first column of the combos query, can you give me an example with code ?
    my code for this sub is :

    Private Sub combobox_AfterUpdate()

    [Textbox].value = [combobox].Column(0)
    end sub

    pls help !

  4. #4
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    try this first

    msgbox [combobox].Column(0)

    what is the valu returned?

    is the name of the combox? Is it combobox

  5. #5
    Join Date
    Jun 2003
    Posts
    20
    If I try this
    msgbox [combobox].Column(0)

    I got a message box with the name of the combo , not the id

    If I try this
    msgbox [combobox].Column(1)
    I got an error message 94
    No authorized use of null?????

    And of course nothing in the text box.

  6. #6
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    here is why

    if you have no value for a column or it does not exist the null error will bubble up

    is the data in the combobox in a table

    if not create a table with 3 fields
    add two records to the 3 column table

    create a combobox from the table and then try the msgbox code

    what are the results?

  7. #7
    Join Date
    Jun 2003
    Posts
    20
    The same again….so let’s resume Igot a dta base called “mydb” witch contains 2 tables, “table1” & “table2” and a form

    Table1 -> id, err
    The data of the id are: 1,2,3
    The data of the err are:aaa,bbb,ccc

    Table2->my_id,error

    The form is based on table2 and contain a combo and a text box. The combo get data from the query:
    Select distinctrow err,id from table1;

    So now how can I select the “bbb” value from the combo and the “2” value will appears in the text box???
    I hope that this schematic can help you!!

  8. #8
    Join Date
    Jun 2003
    Posts
    20

    Red face

    any help here????

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    alazarou,

    It would help if you would check your combobox properties and tell us the following values:

    Column Count:
    Column Widths:
    Control Source:
    Row Source Type:
    Row Source: (cut and paste sql code please!)
    Bound Column:
    Limit To List:
    ...and any events associated with it along with their complete code.

    axsprog's solution should have worked. What you are trying to do is pretty simple, so something simple must be missing here.

    blindman

  10. #10
    Join Date
    Jun 2003
    Posts
    20
    You are right it was so simple, I turned the column count value to 2 and now works !!
    Thank you guys!!!

Posting Permissions

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