Solved Creating a query with 1 table and 4 queries adds a new record

dullster

Member
Local time
Today, 12:46
Joined
Mar 10, 2025
Messages
213
I am building a query to show all payroll taxes for Federal, State, Social Security and Medicare to match the Employee and ClientID. All 4 taxes are in to seperate queries that calculates the tax based on the pay period salary. I'm now combining the Employee table and all 4 queries for taxes. Everytime I add a query with the tax, it adds a new line with the same data as the previous line.

Attached is the Query design with the results. How do i get it to stop listing another line when i add the next tax query?
 

Attachments

I have the taxes all in the same table Federal taxes for Single and Married, State taxes for Single and Married, Social Security for Married and Single, Medicaid for Married and Single. So I need to add a TaxID for each Employee for each tax to the Employee Table?
 
First is advice you should learn in general, but not apply in this particular case:

Divide, isolate and conquer. You've got 5 datasources in your query any of which could be the offending source with "duplicates". So, narrow it down to find out which one the culprit actually is. Start with just tblEmployees and use criteria to isolate to just 1 client/employee/whatever. If you have duplicates when you run it, then tblEmployees is the problem. If not, add a second datasource and rerun, if duplicates its the second datasource's fault. Then do the third like that, then the fourth and then the last one. Whnever you find duplicates you'll know which datasource is at fault and can dive deeper into it to find out why.

Second, you don't need to do that because your premise is wrong. As Pat pointed out you've structured this thing incorrectly. We are only able to glimpse into 1 table and 4 queries. You can't really assess much by looking at queries because you don't know what data goes into them. But I do know that when you have so many queries with similar structures there's probably a better way to get that data into just one query.

Lastly, the one table we can see, tblEmployees, doesn't look right. If DemoClientID is in tblEmployee there's no need for ClientTypeID and ClientTitleID because those most likely belong in the Client table. It's also usually incorrect to use a text field as an ID field. DemoClientID should be numeric, not someone's name. Lastly, why doesn't tblEmployee hold any real information about the employee? No name, no contact info, nothing but marital status.
 
I have cleaned up the Employee table.

Now I want IIf ([tblEmployees].[MaritalStatus]=[tblpayrolltaxes].[MaritalStatus] AND [tblpayrolltaxes].[MyUCA]=21512, [tblpayrolltaxes].[TaxID])

I can't get it to work
 
Define "can't get it to work"?
 
It wouldn't return the ID value. I believe I found another way. As always, I appreciate all your help.
 
Towns have very little liquid revenue available to buy expensive software, therefore, it won't happen and they will continue to use an excel spreadsheet to do the calculations.
 

Users who are viewing this thread

Back
Top Bottom