Problem with SQL query

  • Thread starter Thread starter Zeljko Kacun
  • Start date Start date
Z

Zeljko Kacun

Hi,

following SQL query results with Type Mismatch:

strSqlU = "update t_upisnik set t_upisnik.bodova = SELECT sum(bodova)as
suma from t_prijava where t_prijava.nepogoda = t_upisnik.nepogoda and
t_prijava.kultura = t_upisnik.kultura " & _
" where t_upisnik.ID in (SELECT prijavnik from t_prijava)"

Anyone have any ideas what I did wrong?
 
1) As written, it looks like you have 2 WHERE clauses, which I'm sure
confuses Access. I suspect the first WHERE belongs with the subquery. Try
specifying where that subquery starts & stops:
strSqlU = "update t_upisnik set t_upisnik.bodova = (SELECT sum(bodova)as
suma from t_prijava where t_prijava.nepogoda = t_upisnik.nepogoda and
t_prijava.kultura = t_upisnik.kultura)" & _
" where t_upisnik.ID in (SELECT prijavnik from t_prijava)"

2) I'm not sure the above will fix your " Type mismatch" error, so the next
thing to do would be to make sure that the data types of the fields/values
on either side of all 3 equal signs are the same. Same goes for the IN()
clause. (myText field = myNumeric field would cause a Type Mismatch).

You might try running your 2 subqueries independently to make sure they are
error free and then focus on where they "plug into" this query.

HTH,
 
Back
Top