Accessing excel files using microsoft access

Copper Contributor

Hi

I am trying to automate excel file using Microsoft access. I am using macros for that, but I am not able to get the required output.

I have created one public function in microsoft access and now I am using that function as a "autoexec" macro in access db, but as i am trying to run that macro it is showing that function name not found.

SuperUser20_2-1636464692175.png

 

Now when I am trying to use this function inside the macro, I am getting error

SuperUser20_1-1636464623672.png

And i am getting the below error

SuperUser20_3-1636464750541.png

So what should i do not to get rid of this error

any help would be appreciated

 

12 Replies

@SuperUser20 

 

One common reason for that particular error is that there is a missing reference. Does your code compile?

@George Hepworth 

how to check whether my code is getting compiled or not

@SuperUser20 

Open the VBE and select Debug. Then click on "Compile YourDatabaseNameAppearsHere"

If there is a problem, it'll quickly throw an error.

 

GeorgeHepworth_0-1636484055548.png

 

Also look for missing references here:

GeorgeHepworth_1-1636484196563.png

 

 

Any missing or incorrect references will be flagged as "Missing". 

@George HepworthI have checked and compiled but there is no error and no missing references is there.

Where is the function located, in a standalone module or in the class module of a form?
If the latter, you'll need to add that form reference as part of the call to the function. Better to have it in a standalone module instead.
It is storee in the stand alone module, not in the form module. Even then it is not executing and showing error.
The problem appears to be in the way your macro tries to call the function then. SInce we've only seen the error message, maybe you can share the actual macro as well.

@George Hepworth 

 

The actual macro is

SuperUser20_0-1637036047213.png

I  am using this function for fetching the data but not getting the required output

U@SuperUser20 

 

Unfortunately, it's not possible to diagnose this problem with the limitations imposed by the static posts in this discussion. Nothing appears to be out of the ordinary. The problem occurs during runtime, which we can't watch.

 

It might help if you can upload a sample copy of the accdb as an attachment, with just enough sample data to see how it's supposed to work.

Also, when presenting a problem, it is almost always more helpful to describe behavior, not outcomes. "...not getting the required output" is a statement of an outcome. What we need is a description of the actual behavior. "I expected a recordset to be exported to Excel. Instead I get an error message. The error message says....."

@SuperUser20

 

What is the name of the Module that the Function is contained within?

 

Make sure you do not have a Function inside a Module of the same name, it will result in Error 2425.

 

-Verify that the Module name and Function name are different.