Sub Conexao()
Dim cnx As ADODB.Connection, rs As ADODB.Recordset, cmd As ADODB.Command
Dim sql As String
Application.ScreenUpdating = False
With cnx
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=caminhodoarquivoseubancodedados.accdb;Persist Security Info=False;"
.Open "caminhodoarquivoseubancodedados.accdb"
End With
sql = "SELECT * ... sua cláusula sql
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cnx
.CommandText = sql
.CommandTimeout = 0
End With
Set rs = cmd.Execute
rs.Close
cnx.Close
End Sub
Postado : 15/06/2016 5:37 am