Error in SQL

vieirasoft

New member
Local time
Today, 06:05
Joined
Sep 12, 2018
Messages
5
Good afternoon. I have an sql instruction like that:

...IN 'CurrentProject.Path & " \ historicoapolice.mdb '" & _ But it gives me error

But if i put like this:

....IN ' C:\loja seguros\ historicoapolice.mdb '" & _ it does not matter anymore.


The "historicoapolice.mdb" is a database to store customer history. In the main MDB there is a button. Clicking executes the sql statement and sends the selected tab to history. It is not connected to the main. I would like the sql statement to run anywhere where the mdb was installed, since the folder is the same for both mdb's.
So, rather than ....IN ' C:\loja seguros\ historicoapolice.mdb '" & _, i would like this......IN 'CurrentProject.Path & " \ historicoapolice.mdb '" & _ But it gives me error. Mujst doing something wrong, but what?


What i'm doing wrong? Can someone help me? Thank you
 
I don't think you need all the quotes.?

Just use
"IN " & CurrentProject.Path & "\historicoapolice.mdb"
 
Thank you for your feedback, my friend, but unfortunately it did not work. It still works if you put the path like this: .... IN 'C: \ lojaseguros \ historicoapolice.mdb' "& _, however if i change to
IN "& CurrentProject.Path &" \ historicoapolice.mdb ", does not give error, but does not export the selected client to history, that is historicoapolice.mdb
 
The best way I have found to get past problem like this is to build the SQL string and then debug.print it.? That way you will spot the errors more easily?

So something like.
strSQL = "Select....."
strSQL = strSQL & " WHERE......"
strSQL = strSQL & "ORDER BY....."
Debug.print strSQL

HTH
 
From your last post also try

"IN '" & CurrentProject.Path & "\historicoapolice.mdb" & "'"
 
Dear Gasman. It's ok now. Finally !!! Thank you very much and a great hug from Portugal
 
Good morning

this line worked fully:
IN '" & CurrentProject.Path & "\historicoapolice.mdb" & "'" & _

Thank you
 

Users who are viewing this thread

Back
Top Bottom