Update problem

  • Thread starter Thread starter janne
  • Start date Start date
J

janne

I am trying to update the number of 'yes' from a checkbox field.. I used
this code:

UPDATE tblRapporter
SET Antal = Abs(Sum(tblKontrollrapport.CheckBox5))
WHERE ID=5;

I got the answer: 1 field not updated wrong typeconvert
How to do ??
 
Try this:

UPDATE tblRapporter
SET Antal =
(SELECT Abs(Sum(T.CheckBox5))
FROM tblKontrollrapport AS T
WHERE T.ID = 5)
WHERE ID=5;
 
Uhm, I think you may get the "must use updateable query" error with that
statement.

You might try the following

UPDATE tblRapporter
SET Antal = ABS(DSUM("Checkbox5","tblKontrollRapport","ID=5"))
WHERE ID = 5

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
Very possible, John.... but I was thinking that the lack of an explicit join
might make muster with ACCESS/Jet.
 
Sorry but the suggestions didn't help

Perhaps I was too skimpy when I write down my problem so I try again.
I have 2 tables tblKontrollRapport and tblRapporter
In tblKontrollRapport I have a CheckBox-column and here I want to
count the number of rows where the CheckBox5 is true and move that number
to the field Antal in tblRapporter and ID=5
 
This statement should do what you are asking assuming that the name of
the field is checkbox5. I would usually expect that to be the name of a
control and the field to have a more descriptive name such as
DataIsComplete.


UPDATE tblRapporter
SET Antal = DCount("*","tblKontrollRapport","CheckBox5=True and ID=5")
WHERE ID = 5


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
Back
Top