Reputation: 4386
Ok, this may be a long shot but in MS Access, is it possible to execute VBA using SQL? I'm looking to write a query that runs either a single VBA statement or a Sub. Basically, what I'm trying to do is modify the hidden attribute of a table using SQL.
MS makes enough weird decisions with Office implementations that I'm mildly hopeful this is one of those cases.
Upvotes: 1
Views: 271
Reputation: 13713
You can use user-defined functions within an SQL query ( http://www.sqlexamples.info/SQL/inlineudf.htm ). I doubt Excel checks what you do inside this function, so you probably can do whatever you like.
Upvotes: 0
Reputation: 97101
You can create a VBA function and use the function's return value as a field expression in a query. However, you must run the query from within an Access application session. Otherwise the db engine will not be able to use your custom function.
SELECT YourFunction() AS result;
Upvotes: 6
Reputation: 9552
It's been a few years (thankfully) since I used Access, but to the best of my knowledge, that's simply not possible. You can use VBA to execute SQL, but not vice versa.
Upvotes: 0