Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Not Updatable 2

Status
Not open for further replies.

fredka

Technical User
Jul 25, 2006
114
US
I am having a real hard time understanding how to make this work - I am getting the "query not updatable" error on the following

UPDATE tblSmEmployerGrps INNER JOIN qrySmallEmployerGroups7 ON tblSmEmployerGrps.MAIN_GRP_ID = qrySmallEmployerGroups7.MAIN_GRP_ID SET tblSmEmployerGrps.TotalContracts = qrySmallEmployerGroups7.[CountOfSUBS_ID];


I looked at previous posts and I am just missing it. Any help would be greatly appreciated!!! thanks!!!

Fred
 
you're missing part of the query. The structure for an UPDATE is:
Code:
UPDATE tablename [b]SET FieldName = SomeValue[/b] WHERE conditions

In access you can join into other tables between the tablename and the SET condition, but you still need a SET somewhere.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Thanks for helping me!! I do have a Set in my sql?

Fred
 
I guess there is a SET buried in there....my bad!

not sure what the problem is then.....
 
What is the SQL code of qrySmallEmployerGroups7 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am taking a table with main_grp_id and then counting the people that are enrolled with each main_grp_id. The tblSmEmployerGrps has the main groups numbers and the ENL_SUBS_PRD table has individuals enrolled. Thanks!!

Here is the sql for qrySmallEmployerGroups7:

SELECT qrySmallEmployerGroups6.MAIN_GRP_ID, Count(qrySmallEmployerGroups6.SUBS_ID) AS CountOfSUBS_ID
FROM qrySmallEmployerGroups6
GROUP BY qrySmallEmployerGroups6.MAIN_GRP_ID;

and here is the sql for qrySmallEmployerGroups6:

SELECT tblSmEmployerGrps.MAIN_GRP_ID, ENL_SUBS_PRD.SUBS_ID, ENL_SUBS_PRD.SP_TRMDT, ENL_SUBS_PRD.PRD_ID
FROM ENL_SUBS_PRD INNER JOIN tblSmEmployerGrps ON ENL_SUBS_PRD.MAIN_GRP_ID = tblSmEmployerGrps.MAIN_GRP_ID
WHERE (((ENL_SUBS_PRD.SP_TRMDT)=#12/31/9999#) AND ((ENL_SUBS_PRD.PRD_ID) Like "G*" Or (ENL_SUBS_PRD.PRD_ID) Like "H*" Or (ENL_SUBS_PRD.PRD_ID) Like "B*"));


 
you may try this:
UPDATE tblSmEmployerGrps
SET TotalContracts = DCount("SUBS_ID", "qrySmallEmployerGroups6", "MAIN_GRP_ID=" & [MAIN_GRP_ID])

Assumptions: MAIN_GRP_ID is defined as numeric in tblSmEmployerGrps

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'm sorry, it is a text field.

Fred
 
it is a text field
Code:
UPDATE tblSmEmployerGrps
SET TotalContracts=DCount("SUBS_ID","qrySmallEmployerGroups6","MAIN_GRP_ID='" & [MAIN_GRP_ID] & "'")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
fredka said:
it is a text field.

then you just need to add tick marks:
Code:
UPDATE tblSmEmployerGrps
SET TotalContracts = DCount("SUBS_ID", "qrySmallEmployerGroups6", "MAIN_GRP_ID=[COLOR=red]'[/color]" & [MAIN_GRP_ID] &"[COLOR=red]'[/color]")


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Thanks to you both sooooo much!!!!! Can you explain why this works but the original does not ? thanks again!!!!

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top