Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
  • Avatar do usuário
  • Avatar do usuário
Avatar do usuário
Por Henrique
Posts Avatar
#11320
Não estou conseguindo usar minhas funções ADO .
Meu Office é o Professional Plus 2013 - 64 e quando executo minha rotina dá erro. Já tentei mudar o Provider, mas aí o erro passa para ERRO EM TEMPO DE EXECUÇÃO "-2147467259 (80004005) Não foi possível encontrar ISAM instalável.
Avatar do usuário
Por alexandrevba
Avatar
#11321
Bom dia!!

Eu lhe recomendo postar o arquivo modelo com sua rotina para quem tem essa versão tentar te ajudar.

As bibliotecas foram referenciadas devidamente?

Att
Avatar do usuário
Por Henrique
Posts Avatar
#11359
Obrigado Alexandre.

Segue o modelo no anexo.

O código é o seguinte:
Código: Selecionar todos
Option Explicit

Sub Pegaregistro()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim MyConn As String
Dim FIM As Boolean
Dim StrDB As String
Dim Quote As Variant

sSQL = "SELECT Descrição FROM Teste WHERE Data = 21/05/1967"

MyConn = "D:\Usuarios\Henrique\Documents\Henrique\Homeop\Base.accdb"

    Set cnn = New ADODB.Connection
        With cnn
        .Provider = "Microsoft.ACE.OLEDB.12.0"
        .Open MyConn
    End With
    Set rs = New ADODB.Recordset
    With rs
        .CursorLocation = adUseServer
        .Open Source:=sSQL, ActiveConnection:=cnn, CursorType:=adOpenForwardOnly, LockType:=adLockOptimistic, Options:=adCmdText
    End With
    FIM = False

    Do While Not FIM
        FIM = rs.EOF
        If FIM = True Then
            Exit Do
        End If
        If rs.Fields("Data").Value = "21/05/1967" Then
            Quote = rs.Fields("Descrição").Value
            MsgBox Quote
            FIM = True
            Exit Do
        Else
        End If
        rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    cnn.Close
    Set cnn = Nothing
End Sub
Você não está autorizado a ver ou baixar esse anexo.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord