Jump to content

Eliminar y Modificar Mediante Sql


Recommended Posts

Posted

Hola a todos, me pueden ayudar con el tema de como eliminar y modificar mediante sql. pues un listbox carga los datos mediante consulta sql, yo quiero eliminar el dato q se encuentra seleccionado en el listbox, trate con este código pero me da error. me puede ayudar. muchas gracias por su apoyo.

Application.ScreenUpdating = False
Dim MyArray() As String
Dim Fila As Integer
Dim i As Long
Dim Rw As Integer
Dim Columna As Integer
Dim Rst16 As New ADODB.Recordset
Dim Cnx16 As New ADODB.Connection
Dim Consulta16 As String, UltFila As Long, NombreHoja As String
'Dim IdCodigo As String ',
Dim Codigos As String

Codigos = FrmPersonal.ListBox1.List(FrmPersonal.ListBox1.ListIndex, 0)
'Desc = frm_orden.CbServicio.Text
If Trim(Codigos) = "" Then Exit Sub
Cnx16.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & _
";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
Hoja4.Select
NombreHoja = Hoja4.Name
UltFila = Hoja4.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Consulta16 = "Delete FROM [" & NombreHoja & "$A1:U" & UltFila & "] where [Codigo] = '" & Codigos & "'"

Rst16.Open Consulta16, Cnx16, 1, 1
Rst16.Close
Set Rst16 = Nothing
Cnx16.Close
Set Cnx16 = Nothing
[/CODE]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

Privacy Policy