I am using listview. I am selecting particular row of listview by clicking on that row and after clicking on toolbar's Button, I want that , the data of entire selected row should show in textbox and comboxes of form. I am doing this by calling a function "Editt()" at toolbar's button click event which are as follows : -
Expand|Select|Wrap|Line Numbers
- Option Explicit
- Public con As ADODB.Connection
- Public rs As ADODB.Recordset
- Public Function conn() ' for connection
- Set con = New ADODB.Connection
- con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CCMS.mdb;Persist Security Info=False"
- con.Open "CCMS.mdb"
- End Function
- Public Function reco() ' for recordset
- Set rs = New ADODB.Recordset
- End Function
- ---------------------------------------------------------
- This code gives the row no which is selected by you.
- Private Sub lvwSchlStud_Click()
- If lvwSchlStud.ListItems.Count <> 0 Then
- lvwSchlStud.Tag = lvwSchlStud.ListItems(lvwSchlStud.SelectedItem.Index)
- End If
- End Sub
- =========================================================
- Function Editt()
- If lvwSchlStud.Tag <> "" Then
- Call reco
- rs.Open "select Fname, Lname, Mname, InstName, StdYear, BatchTime, BatchName, BatchType, Gender, ParName, SelfNo, FatherNo, MotherNo, ResiNo, Addr, Email, DOB, Batch, InstType from StudRecord where StudID = " & Int(lvwSchlStud.Tag) & "", con, adOpenStatic, adLockPessimistic
- With frmUpdateStudent
- .txtFirstName.Text = rs!Fname
- .txtLastName.Text = rs!Lname
- .txtMidName.Text = rs!Mname
- .txtInstName.Text = rs!InstName
- .cboStdYear.Text = rs!StdYear
- .cboBtchTime.Text = rs!BatchTime
- .cboBtchName.Text = rs!BatchName
- .cboBtchType.Text = rs!BatchType
- .cboGender.Text = rs!Gender
- .txtParName.Text = rs!ParName
- .txtSelfNo.Text = rs!SelfNo
- .txtFathrNo.Text = rs!FatherNo
- .txtMothrNo.Text = rs!MotherNo
- .txtResiNo.Text = rs!ResiNo
- .txtAddr.Text = rs!Addr
- .txtEmailID.Text = rs!Email
- .DT1 = rs!DOB
- .cboSchlColl.Text = rs!InstType
- .cboBtch.Text = rs!Batch
- End With
- frmUpdateStudent.Show vbModal
- Else: MsgBox "No record is selected!!", vbExclamation, "System Alert"
- End If
- End Function
VB giving me error at - rs.Open "select Fname, Lname, Mname, InstName, StdYear, BatchTime, BatchName, BatchType, Gender, ParName, SelfNo, FatherNo, MotherNo, ResiNo, Addr, Email, DOB, Batch, InstType from StudRecord where StudID = " & Int(lvwSchlStud .Tag) & "", con, adOpenStatic, adLockPessimist ic
One Important thing i want to tell you that - in listview i am showing data in following way-
StudID, Fname, Mname, Lname, InstName, StdYear, BatchTime, BatchName, BatchType, Gender, ParName, SelfNo, FatherNo, MotherNo, ResiNo, Addr, Email, DOB