In my DB I have two Related Tables that I am working with. One table contains customer information:
Table 1
Customer (currently I have 3 customers)
License Purchased (currently from 32 to 72)
Date Purchased
Active licenses (This is what I need computed and stored in this table)
Table 2
This contains a list of licenses used by each customer, some other data fields and a field that shows the customer name. These licenses can be "Active" Y or N.
For this example we will say customer "A" has 32 licenses in table 1 and has 16 of these license in Table 2. Out of the 16 licenses in table 2 10 are active and 6 have expired and are not active. Etc. for customer "B" and "C".
Against Table two I run a totals query to count the "Active" = Y licenses for each customers. This returns each customer name (A, B, C for this example) and the total of active licenses. So customer "A" returns a value of 10.
My question. I need the results of the totals query to be added to the Active Licenses field in TABLE 1. I have tried an Update query to do this but I am failing to get results.
My Totals query is called Count_Customer_Actives. In my Update query, shown below, I felt it was necessary to connect the customer fields from each table so the correct records are updated. This may be my problem but I am not sure how to fix it. Please show me the correct query setup. SQL view will do nicely.
I have done update queries before but for some reason this one is kicking my butt. My goal is to have this work even if my users add or remove customers.
Thanks,
Table 1
Customer (currently I have 3 customers)
License Purchased (currently from 32 to 72)
Date Purchased
Active licenses (This is what I need computed and stored in this table)
Table 2
This contains a list of licenses used by each customer, some other data fields and a field that shows the customer name. These licenses can be "Active" Y or N.
For this example we will say customer "A" has 32 licenses in table 1 and has 16 of these license in Table 2. Out of the 16 licenses in table 2 10 are active and 6 have expired and are not active. Etc. for customer "B" and "C".
Against Table two I run a totals query to count the "Active" = Y licenses for each customers. This returns each customer name (A, B, C for this example) and the total of active licenses. So customer "A" returns a value of 10.
My question. I need the results of the totals query to be added to the Active Licenses field in TABLE 1. I have tried an Update query to do this but I am failing to get results.
My Totals query is called Count_Customer_Actives. In my Update query, shown below, I felt it was necessary to connect the customer fields from each table so the correct records are updated. This may be my problem but I am not sure how to fix it. Please show me the correct query setup. SQL view will do nicely.
Code:
UPDATE Count_Cust_Actives INNER JOIN MS_Contracts ON Count_Cust_Actives.[Name or Location] = MS_Contracts.MS_Contract_Cust SET MS_Contracts.Active_Lic = [Count_Cust_Actives]!Count;
I have done update queries before but for some reason this one is kicking my butt. My goal is to have this work even if my users add or remove customers.
Thanks,