Skip to content
Advertisement

Count how many times certain fields in records with repeating values are found (or not found) in another table

First of all, I wish to say hi to the community here. The posts here have been a great help with VBA but this is my first question ever. I have a task that I need to solve in SQL (in MS Access) but it’s sort of new to me and the task seems to be too complex.

I have a table in Access with the following structure(let’s call it Tinvoices):

This table relates to actions on invoices. Invoices and their related data are repeated with each step. There is another table, which contains agents belonging to a certain department (let’s call it Tdeptusers):

What I need to do is the following. Have distinct lines for the invoices (the most unique key is combining the invoice, year and company) and counting in separate steps have been done by users in the Tdeptusers table and how many by users who are not in Tdeptusers. Something like this:

I’m kind of a beginner, so you’ll have to excuse me in providing usable codes. Being a complete beginner, I got stuck after the absolute basics. I have stuff like this:

This doesn’t give back the desired result, mostly not in actionsByOthers, instead I get huge numbers. Maybe something similar to this solution might work but I haven’t been able to do it. Much appreciation for the help, folks.

Advertisement

Answer

Use proper standard explicit JOIN syntax :

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement