Results 1 to 4 of 4

Thread: Big Combobox problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262
    Hi group,

    please help me out with this one.
    I am using ADO
    I have a combobox on a form.
    The combobox is filled with all records from the table tblFUNCTION. This table has 2 fields:
    FunctionID (Primary Key)
    Description

    I also have a table tblEMPLOYEE. This table has the following fields:
    employeeID
    Name
    FunctionID
    etc.
    etc.
    etc.

    The tables are linked via the field FunctionID.

    I use this code to show both fields (FunctionID & Description) in the combobox:

    cboFunctionID.Clear
    Do Until rstMedFunctionID.EOF
    cboFunctie.AddItem rstMedFunctie.Fields("FunctionID") & " " & rstMedFunctie.Fields("Description")
    rstMedFunction.MoveNext
    Loop

    I use this code to save the new record:
    Dim sFunction,sID,sName As String

    sID = txtMedewerkerID
    sName = txtName
    sFunction = cboFunction

    rstEmployee.AddNew
    rstEmployee!EmployeeID = sID
    rstEmployee!name = sName
    rstEmployee!FunctionID = sFunction(This line gives an error)
    rstEmployee.Update

    MY QUSTION:
    When I select a function using the combobox, how in Gods name, do I save the functionID in the table tblEmployee???

    If something isn't clear do ask!

    Thanks in advance!

    Sander

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262
    Thanks for the reply.

    First of all I didn't check it before. I've checked it and they are both numeric fields and the field length is set to long integer.

    Hope this helps.

    Regards,

    Sander

    PS: i did not design the database!

  3. #3
    Guest
    Hi, to get the item being displayed in the combo box u use something like

    ---
    rstEmployee!FunctionId = cboFunctionId.list(cboFunctionId.listindex)

    ---
    Please check if the datatypes for the FunctionID and the value being returned from the combo box are the same. As i find from ur post that you are adding the item as FunctionId & Description. Please do check this out. I am available at [email protected] for further queries if any.

    All the best...vijay

  4. #4
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Lightbulb Try this

    What you can try to do is running the function before you save it to the field. Somewhat like this: (I am not sure that this will work, but hey, give it a try)

    dim response as integer

    response = function(parameter)

    with rs
    rs.field("fieldname") = response
    end with

    you can also try to put a message box before you save it to make sure that the function is passing the correct value (you know, for debugging purposes).

    Hope this helps.

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