You are on page 1of 1

Private Sub ImportarDatos_Click()

Dim conectar As String


Dim sPath As String
Dim sql As String
Dim cn As ADODB.Connection
sPath = ThisWorkbook.Path & "\BaseCliente.accdb"
conectar = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sPath & ";Persist
Security Info=False;"
Set cn = New ADODB.Connection
cn.Open conectar
sql = "insert into CLIENTES (NOMBREC, IMPORTEC, PAISC) values('" & Cells(3,
3).Value & "', '" & Cells(3, 4).Value & "', '" & Cells(3, 5).Value & "')"
cn.Execute sql
cn.Close
Set cn = Nothing
LimpiarRegistros
MsgBox "Datos Registrados con Exito", vbInformation, "Excel a Access"
End Sub

Private Sub ExportarDatos_Click()


Dim conectar As String
Dim sPath As String
Dim sql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
sPath = ThisWorkbook.Path & "\BaseCliente.accdb"
conectar = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sPath & ";Persist
Security Info=False;"
Set cn = New ADODB.Connection
cn.Open conectar
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
End With
sql = "select * from CLIENTES"
rs.Open sql, cn
Range("B8").CopyFromRecordset rs
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub

Sub LimpiarRegistros()
'Application.ScreenUpdating = False
Range("B3:E3").ClearContents
'Application.ScreenUpdating = True
End Sub

UPDATE tabla
SET nuevo_valor
WHERE criterios;

You might also like