Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Edit an EXCEL Worksheet!!!!!!

Status
Not open for further replies.

bhuts

Programmer
Nov 9, 2000
2
US
Hi!
As a newcomer to VB,I face the following problem:

NAME IDNO AGE SEX
aaa 24 male
bb male
aaaa 678
cc 434 23
mujje 2222 21 male
(The alignment of the entries might get distorted after I post it)
My EXCEL WORKSHEET(which is obtained from another application) contains data as shown above.After I display a record (in combo box and text boxes)for which entries are incomplete(say,for cc)and try to complete the entries(here for cc it's SEX) I get ERROR:
"DATA TYPE CONVERSION ERROR"
(textsex.text="some text I put",data1.recordset.fields (SEX)=Null)
How to get rid of this????
CODE for displaying records:
Data1.Recordset.MoveFirst
While Not Data1.Recordset.EOF
If ComboNAME.Text = Data2.Recordset.Fields(NAME) Then
TextIDNO.Text = Data2.Recordset.Fields(IDNO) & ""
TextAGE.Text = Data2.Recordset.Fields(AGE) & ""
TextSEX.Text = Data2.Recordset.Fields(SEX) & ""
Exit Sub
Else
Data1.Recordset.MoveNext
End If
Wend

CODE for editing records:
Data1.Recordset.Edit
If ComboNAME.Text = Data1.Recordset.Fields(NAME) Then
Data1.Recordset.Fields(IDNO) = TextIDNO.Text
Data1.Recordset.Fields(AGE) = TextAGE.Text
Data1.Recordset.Fields(SEX) = TextSEX.Text
Data1.Recordset.Update
End If

(NAME displayed in the combo box is NOT EDITABLE).
PLEASE SHOW ME SOME WAY OUT......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top