Private Sub btnedit_Click()

Dim a As Variant
Set conn = New ADODB.Connection
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SPUM;Data Source=(LOCAL)"
conn.ConnectionString = strConn
conn.CursorLocation = adUseClient
conn.Open
'lblindexid.Caption = rs!Indexid

strsql = " Select * from ES_otherSchools where Indexid = '" & lblindexid.Caption & "' "
Set rs = conn.Execute(strsql)


strsql = " Update ES_OtherSchools set SchoolCode = '" & txtschoolcode.Text & _
"', SchoolName = '" & txtnameofschool.Text & "', Shortname = '" & txtshortname.Text & _
"', Address = '" & txtaddress.Text & _
"', Telephone = '" & txttelno.Text & "', Fax = '" & txtfax.Text & _
"', URL = '" & txturl.Text & "', Email = '" & txtemail.Text & _
"', InsClassCode = '" & cboschoolclass.Text & "' where Schoolcode = '" & lblschoolcode.Caption & "' "

With msflex
If txtschoolcode.Text = .TextMatrix(.Row, 0) And txtshortname.Text = .TextMatrix(.Row, 1) Then
MsgBox "School Code Must not the same to other...", vbExclamation, "Invalid Input"
Else
Set rs = conn.Execute(strsql)
End If
End With

MsgBox ("Record Edited.."), vbInformation, "System Message"
strsql = "Select * from ES_OtherSchools"
Set rs = conn.Execute(strsql)
'rs.Open strsql, conn, adOpenDynamic, adLockOptimistic
btnedit.Enabled = False
msflex.Rows = 1
While Not rs.EOF
msflex.AddItem rs!Schoolcode & vbTab & _
rs!SchoolName & vbTab & _
rs!ShortName & vbTab & _
rs!Address & vbTab & _
rs!Telephone & vbTab & _
rs!Fax & vbTab & _
rs!URL & vbTab & _
rs!Email & vbTab & _
rs!InsClassCode & vbTab
rs.MoveNext
Wend
Call Clear
conn.Close
End Sub

how can i update record i am a newbie here...

how can i update this one??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.