PDA

Click to See Complete Forum and Search --> : Why doesn't this code work for updating the recordset?


Spawny
Jun 29th, 1999, 03:29 PM
Hi, I have a program where when you edit it brings up all the data. the user can edit the fields but some fields wont update. the code i have for text boxes is:

mrstrans as recordset

fldName = "Source"
mRstrans.Fields(fldName).ValidateOnSet = True
mRstrans.Fields(fldName) = TxtDetails(15).Text

Now this works fine but if i want a combo box to update it spits the dummy. The code i have for that is :

fldName = "Status"
mRstrans.Fields(fldName).ValidateOnSet = True
mRstrans.Fields(fldName) = CmbType.ItemData(CmbCmbType.ListIndex)

cmbgender is the combo box. it comes up on the form no probs but if ya edit it it dont do jack. Now my question is: Am i using the right coding to get this to update the combo box selected? Any help would be great.

cath
Jun 29th, 1999, 03:51 PM
Instead of using this :

mRstrans.Fields(fldName) = CmbType.ItemData(CmbCmbType.ListIndex)

could you not use

mRstrans.Fields(fldName) = CmbType.text

??

Parth
Jun 30th, 1999, 03:58 PM
I need a clarification from your end. The code which you have given has the following line :

CmbType.ItemData(CmbCmbType.ListIndex)

Are you sure, the value which you want to write in the recordset is coming from the combox "Cmbtype" as the listindex is returning the currently index of combobox "CmbCmbType", which is diferent from "CmbType"

Spawny
Jun 30th, 1999, 04:23 PM
Parth Wrote:

I need a clarification from your end. The code which you have given has the following line :
CmbType.ItemData(CmbCmbType.ListIndex)

Are you sure, the value which you want to write in the recordset is coming from the combox "Cmbtype" as the listindex is returning the currently index of combobox "CmbCmbType", which is diferent from "CmbType"

No i am not sure about the value coming from the combo box. How would i check to make sure it is coming from that?

Well i have these lines in my initialise combos sub :
CmbType.AddItem "Active"
CmbType.ItemData(CmbType.NewIndex) = 1
etc... over and over up to 4 indexes...

now what i want is it to load what is in the databse already say index 1 meaning active in the combo box but i also want it to update the database if i select say number 2 index.
As for "cmbcmbtype", i am unsure myself what you mean. Basically the line i have given you doesn't update properly but i have used the same line in other projects and it has worked so i am lost for ideas. Thanx for trying to help and understand. If you get something from this then let me know.