so here's my problem.
I have a MS Hierarchical Flex Gird Control [fgdCompany] which is used to display records that are taken from a database. Everything works great but not the Delete button. What the delete button is supposed to do is when a record is selected in fgdCompany, it is supposed to delete that current record. But the problem is, it always deletes the first record in the fgdCompany. Not the record that is selected in fgdCompany. What I am doing wrong? Please help me debug this error!!!!
Code used by me for the Delete button is given below :
Dim rsCompany As New ADODB.Recordset Dim cn As New ADODB.Connection Dim strSQL As String cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=" & App.Path & "\Sample.mdb;" & _ "Persist Security Info:False" cn.Open strSQL = "SELECT [Company].* FROM [Company]" rsCompany.Open strSQL, cn, adOpenStatic, adLockPessimistic If rsCompany.RecordCount > 0 Then msg = MsgBox("Delete Record?", vbYesNo) If msg = vbYes Then rsCompany.Delete rsCompany.MovePrevious If rsCompany.EOF Then rsCompany.MovePrevious ElseIf rsCompany.BOF Then rsCompany.MoveNext End If If rsCompany.EOF And rsCompany.BOF Then txtName = "" txtAddress = "" txtTelephoneNo = "" txtVehiclesReg = "" Exit Sub End If End If If rsCompany.Fields("Company Name") <> "" Then txtName = "" End If If rsCompany.Fields("Address") <> "" Then txtAddress = "" End If If rsCompany.Fields("Telephone Numbers") <> "" Then txtTelephoneNo = "" End If If rsCompany.Fields("Vehicles Registered") <> "" Then txtVehiclesReg = "" End If ElseIf rsCompany.RecordCount = 0 Then txtName = "" txtAddress = "" txtTelephoneNo = "" txtVehiclesReg = "" MsgBox "No records to be deleted." End If Set fgdCompany.DataSource = rsCompany If rsCompany.RecordCount <> 0 Then rsCompany.Update End If