Hi guys,
nice to meet you All!
I am struggling with Excel, trying to get data from an .mdb Access old db,
via SQL query "only".
I mean "only", cause I am able to get what I need by "looping" through records without
errors, but I assume using SQL is extremely better!
So, code you will see below, is ok in order to get connected to the db and
I can easily get recordset content by looping,
but I did a lot of tentatives with queries you will see and
in no one case (you see only two here) I was able to run correctly the query
cause I always get "query sintax error" when executed.
Where is my error ?
To be clear in advance, I cannot use ADO or DAO to connect, cause this is a very old
db and also a very old xls with dozens of macros with the same kind
of connection method you see below.
Thank you in advance,
Fred!
------------------
Private Function aggiorna_comm(stringa_connessione, valuex) As Boolean
On Error GoTo Err_aggiorna_comm
Dim db_destination As Database
Dim rs_destination As Recordset
Set db_destination = OpenDatabase(stringa_connessione)
Set rs_destination = db_destination.OpenRecordset(tabx)
1)
strQry = "SELECT * FROM '" & tabx & "' WHERE '" & fieldx & "' = '" & valuex & "'"
2)
strQry = "SELECT * FROM "&tabx&" WHERE "&fieldx&" = " & valuex & "' "
db_destination.Execute strQry
test = rs_destination!idComm
Err_aggiorna_comm_exit:
rs_destination.Close
Set rs_destination = Nothing
db_destination.Close
Set db_destination = Nothing
Exit Function
Err_aggiorna_comm:
MsgBox Error$
Resume Err_aggiorna_comm_exit
End Function
nice to meet you All!
I am struggling with Excel, trying to get data from an .mdb Access old db,
via SQL query "only".
I mean "only", cause I am able to get what I need by "looping" through records without
errors, but I assume using SQL is extremely better!
So, code you will see below, is ok in order to get connected to the db and
I can easily get recordset content by looping,
but I did a lot of tentatives with queries you will see and
in no one case (you see only two here) I was able to run correctly the query
cause I always get "query sintax error" when executed.
Where is my error ?
To be clear in advance, I cannot use ADO or DAO to connect, cause this is a very old
db and also a very old xls with dozens of macros with the same kind
of connection method you see below.
Thank you in advance,
Fred!
------------------
Private Function aggiorna_comm(stringa_connessione, valuex) As Boolean
On Error GoTo Err_aggiorna_comm
Dim db_destination As Database
Dim rs_destination As Recordset
Set db_destination = OpenDatabase(stringa_connessione)
Set rs_destination = db_destination.OpenRecordset(tabx)
1)
strQry = "SELECT * FROM '" & tabx & "' WHERE '" & fieldx & "' = '" & valuex & "'"
2)
strQry = "SELECT * FROM "&tabx&" WHERE "&fieldx&" = " & valuex & "' "
db_destination.Execute strQry
test = rs_destination!idComm
Err_aggiorna_comm_exit:
rs_destination.Close
Set rs_destination = Nothing
db_destination.Close
Set db_destination = Nothing
Exit Function
Err_aggiorna_comm:
MsgBox Error$
Resume Err_aggiorna_comm_exit
End Function