Skip to content
Advertisement

to use module in sql ms-Access-2010

I have defined a procedure in my module, returning the path of the database and I want to use that path in my sql query.

Procedure in module :

I am using the function above in my sql query :

It is giving me the error: “error in from clause”

but when I am using it in vba code , it is working fine

Any Solution ?

Advertisement

Answer

This is dynamic SQL. You seem to already have found the solution: use VBA code. You can only use functions to return values in static SQL.

If you want to return operators or other things that aren’t standard values, you need to use dynamic SQL, and thus need to use VBA.

You can create queries through VBA if you want, but note that once they are created, they are static.

Sample code to create a query with your function

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement