2

I have a function that creates a text file and need to run it from the data macro. so then the evens can use it on the table. How do I go about doing this?

2 Answers 2

4

You don't, as per our chat. Data macros even run outside of MS Access, if they used code within MS Access, this could not happen. They are tied to the database engine, which knows nothing about Access front-end.

You can run queries from a data macro AFAIK, and it is possible to create a query to write to a file*, but you cannot run VBA.

* I looked into this a little more and I find: "Queries that contain linked tables, action queries, and database references are not allowed in data macros."

Sign up to request clarification or add additional context in comments.

4 Comments

Hmmm I've been trying to investigate other ways of doing it but still getting confused haha. So how do I run the code from the data macro?
Ohhh right. Back to the drawing board. Thanks alot for all your help.
See my response - you don't have to go back to any drawing board - you can call VBA code from those macros - this will of course thus assume that your be running and have Access running for this.
From a previous post, it seems that the relevant Access file is updated by another application, so Access is not running, hence the search for a table trigger rather than a coded trigger.
4

You can do this, but it not recommend. Remember, table triggers and store procedure code does run independent of VBA and in fact it runs even if you don't have Access installed.

However, assuming you going to be using Access to always edit the data (a reasonable assumption), then you can in fact have the table macro call VBA code. There are several ways of doing this, but the most common and useful is to set SetLocalVar to a VBA function. This has the added bonus of being able to pass some values to that function which in most cases is likely required.

So, keep in mind you can call VBA code, but then you are adding creating a dependence from your tables to VBA.

So just use SetLocalVar to some dummy var, and place the VBA function in the expression.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.