Re: Use Function in Query problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Stefan,

1. I'm assuming there is a typo in the QueryVar function, because the
return value is QueryVal, not QueryVar.

2. Not sure why you even need the function if all you are doing is passing
it a path and returning the same value.

3. The IN clause requires that the file name be wrapped in single or double
quotes. So it should read something like:

Dim SQL as string

SQL = "INSERT INTO ArchiveTable (Field1, .....) " _
& "IN '" & QueryVar([FieldName]) & "' " _
& "SELECT ..... FROM ArchiveTmp"

currentdb.execute SQL


HTH
Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Stefan Hoffmann" wrote:

hi Marco,

Co wrote:
Now I run a query saying:
INSERT INTO ArchiveTable ........ IN QueryVar SELECT ........ FROM
ArchiveTmp;
I'm getting an error saying he can't find the path.
What am I doing wrong here?
You cannot use a expression after IN, there must be a constant.

I assume you have a saved query, let's call it qryArchive. Then you can
do this:

Dim db As DAO.Database
Dim SQL As String

SQL = "INSERT INTO ArchiveTable ........ " & _
"IN " & QueryVarOrPathVariable & " " & _
"SELECT ........ FROM ArchiveTmp;"

Set db = CurrentDb
db.QueryDefs.Item("qryArchive").SQL = SQL
Set db = Nothing


mfG
--> stefan <--

.