startuga Posted June 3, 2014 at 11:45 AM Report #558049 Posted June 3, 2014 at 11:45 AM Boas No código abaixo, não consigo fazer a pesquisa através da data, se meter a data a mão! Funciona mas se usar a variavel da data não dá rebenta logo :c Penso que seja por a data ir assim (03-06-2014).. Alguem me consegue ajudar? Dim conn As Object Set conn = CreateObject("ADODB.Connection") Dim data_time As String data_time = Format(Date, "MM/dd/yyyy") Dim cn As Object Dim rs As Object Dim strSQL As String Dim strConnection As String Set cn = CreateObject("ADODB.Connection") strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=C:\QA\QA\NEW V1.0\Mapa Pesos e Ciclos.mdb" 'strSQL = "SELECT molde FROM historico WHERE molde = ('" & txt_mold & "')" strSQL = "SELECT molde, data FROM historico WHERE molde = ('" & txt_mold & "') and data = (data_time)" cn.Open strConnection Set rs = cn.Execute(strSQL) If rs.EOF = False Then MsgBox ("Esse registo já existe!!") Else MsgBox (".|.") End If rs.Close Set rs = Nothing cn.Close Set cn = Nothing
nelsonr Posted June 3, 2014 at 01:41 PM Report #558062 Posted June 3, 2014 at 01:41 PM Alguma razão para usares o CreateObject em vez de OleDbConnection?
gastao Posted June 4, 2014 at 11:43 AM Report #558186 Posted June 4, 2014 at 11:43 AM eu segui o conselho do nelson num post anterior e é uma questão de adaptares que funciona, usando paramentros...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now