Link to home
Start Free TrialLog in
Avatar of Tom Farrar
Tom FarrarFlag for United States of America

asked on

Excel Table Linked To Access Query

I have an Excel table linked to an Access query, Microsoft Office 365 ProPlus.  In the Access query I am eliminating certain records based on <> Criteria.  The record count from the query is 62 records.  When I refresh the Excel table, the record count is 75 records.  The 13 different count is due to the <> Criteria in the Access query.

What am I missing here?  Why is the Excel linked table bringing the records across that the Access query is eliminating?  I'm just not getting it.  Where might I be going wrong?  Thanks.  - Tom
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Perhaps when you refresh Excel, ..."all" the records are being brought in again.
If you refresh excel, ...then close and re-open the Access query, ...is the recordcount back to 62?
Avatar of Tom Farrar

ASKER

Record count is still 75.  The database resides on a company shared drive, and my spreadsheet is on my desktop.  Didn't seem to be a problem earlier.
Check the criteria to make sure it is still there.
Close the query.
Relink the spreadsheet.
Run the query - is the criteria being applied?
You should see 75 records if you open the linked sheet in datasheet view but only 62 if you open the query.
The criteria is still there.  There are actually 918 records in the linked spreadsheet.  There are 3 criteria using "AND" in the Access query, with two of them working, but not the third in the linked spreadsheet.  

I did relink the spreadsheet starting from scratch, and the Access query shows 62 records and the linked spreadsheet shows 75 records.  The difference is the "Not like INT*" in the Access query.

You've given me some things to think about.  I am going to try one criteria at a time in the query to see if that works with the spreadsheet.  Back soon.
There are 3 criteria using "AND" in the Access query, with two of them working, but not the third in the linked spreadsheet
I am confused by this statement.  I thought all the criteria were in the Access query.

Try applying the criteria one at a time so see if they are working as you expect.
Hmmmmm..  The Excel spreadsheet linked to the Access query works with the first two criteria, but not the third when I use "Like*", or "Not Like*" in the query.  The Like and Not Like work in the Access query, but do not carry over to the Excel table.  However, when I us the entire code criteria in the Access query "In (INT1, INT2, INT3)" the query works in Access and the correct record count carries over to Escel.  What is this about?
The criteria are in the Access query.  The results of two of the criteria successful carry over to the linked spreadsheet.  The third criteria (Like*) works for the Access query results but does not carry over to the spreadsheet.  But when I change the Like* to a list the criteria works for Access and for Excel.
The Like and Not Like work in the Access query, but do not carry over to the Excel table.
I don't know what this statement means.  Are you trying to run the Access query from Excel?  That doesn't make sense when the Access query is looking at the linked spreadsheet and I doubt you would even "see" that particular query in Excel anyway.  Excel only "sees" queries it can run.  You said you had an Access query that includes the three criteria and it works correctly on the linked spreadsheet.  I do not understand what problem you are having.  What does "carry over" mean?  Please try to use precise, technical terms to describe exactly where the error occurs.
Okay, first of all, the problem is fixed.  "Like" and "Not Like" are expressions in the Access query that narrows the query selection to records like or not like the criteria (I know you know this, but...)  For instance if my Access tables of names included:

Carr
Smith
Jones
White
 
and I used Like "C", the query would return "Carr".  Likewise if I used Not Like "C" in the criteria, the query would return "Smith", "Jones", "White".  Right?

What I was saying is the Access query worked with the "Like" and "Not Like" criteria and filtered the output accordingly.  But when I refreshed the spreadsheet linked to the Access query, the criteria of Like and Not Like did not work.

However, when I stopped using Like and Not Like in the Access query and replaced it with a specific list of criteria, the output in the Access query and the output in the linked spreadsheet agreed.  Don't ask me why...
Did you close the query after/before you refreshed the link?  And then rerun the query?  If you have the query open, refreshing the link will not cause the query to rerun.  You need to close it and reopen it.  You could press the refresh button but that will not pick up new records.  You actually have to close the query and open it again.
I closed and reopened the query multiple times.  I stand by what I said until someone proves me wrong.  Strange as it is the query output only was reflected correctly in the linked pivot table after I changed the criteria from Like "INT*" to In (INT1, INT2).   Since I have solved the issue this way, I am okay with closing this question.  I will leave it open for a few days to see if anyone else has a comment, then I will close the question.  Thanks both of you for the input.  - Tom
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, Pat, that seems to be the problem.
I'd like to award the points to Pat.  She is correct in her response today.
see ID: 41704056
Thanks. Pat.
You're welcome.