I have 2 tables involved:[Voucher Data Table] and [UDS Age & Gender Table]. I need to update the total NumOfEnctrs for each person in a given year(i.e. how many times each id has seen the doctor that year). I have created a query that gives me the correct count
Count Encounters Query)
PARAMETERS [Enter Calendar Year] Value;
SELECT [UDS Age & Gender Table].pID, Count([Voucher Data Table].[Voucher #]) AS [Count]
FROM [Voucher Data Table] RIGHT JOIN [UDS Age & Gender Table] ON [Voucher Data Table].pID = [UDS Age & Gender Table].pID
WHERE (((DatePart("yyyy",[Date Issued]))=[Enter Calendar Year]))
GROUP BY [UDS Age & Gender Table].pID;
My problem has been getting the [UDS Age & Gender Table] updated with the correct number of encounters, It keeps giving me all encounters regardless of the year they were seen. Here is the sql I'm using:
PARAMETERS [Enter Calendar Year] Value;
UPDATE [Voucher Data Table] RIGHT JOIN [UDS Age & Gender Table] ON [Voucher Data Table].pID=[UDS Age & Gender Table].pID SET [UDS Age & Gender Table].NumOfEnctrs = DCount("*","[Voucher Data Table]","[Voucher Data Table].pId=" & [UDS Age & Gender Table].pID)
WHERE (((DatePart("yyyy",[Date Issued]))=[Enter Calendar Year]));
I know there must be an easier way, can you help?
Thanks
PARAMETERS [Enter Calendar Year] Value;
SELECT [UDS Age & Gender Table].pID, Count([Voucher Data Table].[Voucher #]) AS [Count]
FROM [Voucher Data Table] RIGHT JOIN [UDS Age & Gender Table] ON [Voucher Data Table].pID = [UDS Age & Gender Table].pID
WHERE (((DatePart("yyyy",[Date Issued]))=[Enter Calendar Year]))
GROUP BY [UDS Age & Gender Table].pID;
My problem has been getting the [UDS Age & Gender Table] updated with the correct number of encounters, It keeps giving me all encounters regardless of the year they were seen. Here is the sql I'm using:
PARAMETERS [Enter Calendar Year] Value;
UPDATE [Voucher Data Table] RIGHT JOIN [UDS Age & Gender Table] ON [Voucher Data Table].pID=[UDS Age & Gender Table].pID SET [UDS Age & Gender Table].NumOfEnctrs = DCount("*","[Voucher Data Table]","[Voucher Data Table].pId=" & [UDS Age & Gender Table].pID)
WHERE (((DatePart("yyyy",[Date Issued]))=[Enter Calendar Year]));
I know there must be an easier way, can you help?
Thanks