Hello,
I am trying to connect an Excel 2010 workbook to an Access 2010 database (2007 type) query to use as a PivotTable source, using Data > Connections > Add... . I can establish a connection to the db itself but I noticed that a few queries do not show up in the table/query selector wizard, one of those being my target query.
I have done the following:
• Created a connection to a working query and then changed the command text to point to the target query. Set as PivotTable source. Error: "The query did not run, or the database table could not be opened." then "Problems obtaining data."
• Copied the target query's SQL as the command text. Set as PT source. Error: "Undefined function 'Nz' in expression." then "Problems obtaining data."
• Created a connection to a similar-sized working query that uses many tables and queries, including linked tables and union queries. Set as PT source, working. In Access, changed one of the fields from "[Field1]" to "Nz([Field1])". Refreshed PT, same error as first bullet point.
• Created a copy of the target query, removed all instances of "Nz" in its SQL, and created the connection in Excel. Set as PT source, confirmed working.
So it looks like Excel doesn't like the Nz() function, however this plays an important role in my target query. Given the complexity of the query, it will take several hours of work to avoid using Nz() but maintain the same level of data integrity/validation.
I am posting this here with the the following purposes:
1) to check if anyone knows of a workaround to this issue before I invest the hours to redesign the query and all those that contribute to it
2) to provide the findings above in the hope that it will help somebody Googling the same problem at some point in the future (hello from the past!
) because I sure couldn't find anything at all.
Going forward I will bear this issue in mind and probably avoid using Nz(), as nice as the function is, since I use both Excel and Access in equal amounts and I'm sure there'll be many more overlaps in my work in the future.
So for the meantime... any ideas on how to get around Excel not recognising the Nz() function when connecting to an Access query?
Cheers
I am trying to connect an Excel 2010 workbook to an Access 2010 database (2007 type) query to use as a PivotTable source, using Data > Connections > Add... . I can establish a connection to the db itself but I noticed that a few queries do not show up in the table/query selector wizard, one of those being my target query.
I have done the following:
• Created a connection to a working query and then changed the command text to point to the target query. Set as PivotTable source. Error: "The query did not run, or the database table could not be opened." then "Problems obtaining data."
• Copied the target query's SQL as the command text. Set as PT source. Error: "Undefined function 'Nz' in expression." then "Problems obtaining data."
• Created a connection to a similar-sized working query that uses many tables and queries, including linked tables and union queries. Set as PT source, working. In Access, changed one of the fields from "[Field1]" to "Nz([Field1])". Refreshed PT, same error as first bullet point.
• Created a copy of the target query, removed all instances of "Nz" in its SQL, and created the connection in Excel. Set as PT source, confirmed working.
So it looks like Excel doesn't like the Nz() function, however this plays an important role in my target query. Given the complexity of the query, it will take several hours of work to avoid using Nz() but maintain the same level of data integrity/validation.
I am posting this here with the the following purposes:
1) to check if anyone knows of a workaround to this issue before I invest the hours to redesign the query and all those that contribute to it
2) to provide the findings above in the hope that it will help somebody Googling the same problem at some point in the future (hello from the past!

Going forward I will bear this issue in mind and probably avoid using Nz(), as nice as the function is, since I use both Excel and Access in equal amounts and I'm sure there'll be many more overlaps in my work in the future.
So for the meantime... any ideas on how to get around Excel not recognising the Nz() function when connecting to an Access query?
Cheers