-
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
-
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!
-
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
-
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.