Error in SQL (1 Viewer)

vieirasoft

New member
Local time
Today, 01:42
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:42
Joined
Sep 21, 2011
Messages
14,238
I don't think you need all the quotes.?

Just use
"IN " & CurrentProject.Path & "\historicoapolice.mdb"
 

vieirasoft

New member
Local time
Today, 01:42
Joined
Sep 12, 2018
Messages
5
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:42
Joined
Sep 21, 2011
Messages
14,238
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:42
Joined
Sep 21, 2011
Messages
14,238
From your last post also try

"IN '" & CurrentProject.Path & "\historicoapolice.mdb" & "'"
 

vieirasoft

New member
Local time
Today, 01:42
Joined
Sep 12, 2018
Messages
5
Dear Gasman. It's ok now. Finally !!! Thank you very much and a great hug from Portugal
 

vieirasoft

New member
Local time
Today, 01:42
Joined
Sep 12, 2018
Messages
5
Good morning

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

Thank you
 

Users who are viewing this thread

Top Bottom