Avatar billede cnmdk Nybegynder
17. december 2012 - 12:39 Der er 6 kommentarer og
1 løsning

Data From Access to Excel- undefined function error

Hi,

I use VBA in Access to write custom functions used in queries. Subsequently I need to run the query from excel but I get an undefined function error. I use ODBC to import the data to excel- help anyone?
Christian
Avatar billede terry Ekspert
17. december 2012 - 18:57 #1
thats because the function is in Access and its unknown to ODBC. An idea would be to put the result of your query in a TEMP table.
Avatar billede cnmdk Nybegynder
17. december 2012 - 23:12 #2
Thanks. I think your idea works since I tried to put the data in a table and then it worked. The only thing is that I would like to permit the user to update the data from excel. Two questions:
1. Do I also get the undefined function error if I write VBA/adodb code?
2. Would I be able to create a query that updates a given table with the result of my query every time its executed (I mean it would have to delete the old stuff and replace with query data)?
Thanks,
Christian
Avatar billede terry Ekspert
18. december 2012 - 19:44 #3
I dont work with Excel so often I cant be 100% in my answers on Excel

1. Are you suggesting that you make the same functions in Excel?
  You could try but I dont think it will work.
2. You said "I think your idea works since I tried to put the data in a table and then it worked". Did you execute the query from Excel? If that is the case then YES. You would also be able to run a delete query in the same way.

It is possible to automate Access from Excel using VBA code, this woukld allow you to run any queries, also those containing user defiend functions. So you could run a query to empty the tabel and then the query to insert the result set from your select query.
Avatar billede cnmdk Nybegynder
02. januar 2013 - 08:58 #4
solved
Avatar billede terry Ekspert
02. januar 2013 - 18:57 #5
great, how?
Avatar billede terry Ekspert
09. januar 2013 - 18:58 #6
could you tell us HOW you solved please?
Avatar billede cnmdk Nybegynder
28. juli 2013 - 10:57 #7
Terry, Sorry about not answering. Since you solved my problem I never logged in after closing the issue. Here is a summary of the solution you suggested.
1. Write all the queries with custom functions in access that you need.
2. Create a table in the access database and put your data here after having run your queries with custom functions.
3. Run all your queries in in a procedure from Excel
4. Query your table from excel.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester