Error you tried to execute a query that does not include the specified expression

jex57

Board Regular
Joined
Oct 29, 2015
Messages
62
Hi,
Keep on getting error

"you tried to execute a query that does not include the specified expression"

My SQL looks as follows:

UPDATE TblField LEFT JOIN TblTempStats ON TblField.DomainCatID = TblTempStats.DomainCatID SET TblTempStats.EmptyFields = Sum(IIf([fieldname] Is Null,1,0));


Any ideas as to why? Sorry for all the questions, am battling my way through


Thank you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What are you trying to do?

You are joining a table to itself, which isn't that unusual, however you are joining on the same field which is.

You also have a Sum which doesn't make sense without a group query and do you really have a field called [Fieldname] ?

If you explain what you are trying to do (with table and field names) then hopefully someone will be able to help :)
 
Upvote 0
What are you trying to do?

You are joining a table to itself, which isn't that unusual, however you are joining on the same field which is.

You also have a Sum which doesn't make sense without a group query and do you really have a field called [Fieldname] ?

If you explain what you are trying to do (with table and field names) then hopefully someone will be able to help :)


Hi,

I managed to come right - what I did was:


newSQL1 = "UPDATE TblTempStats " _
& "SET TblTempStats.EmptyFields =" _
& "DSum( " _
& " 'IIf([fieldname] Is Null,1,0)'," _
& "'TblField'," _
& "IIf( " _
& " TblTempStats.DomainCatID Is Null," _
& "'TblField.DomainCatID Is Null'," _
& "'TblField.DomainCatID = ' & TblTempStats.DomainCatID ) )"
 
Upvote 0
Do you actually have a field in your table called "EmptyFields"? That's awfully awkward SQL but it's hard to tell what you are doing without some example. A little strange to call a table Field also (tblField). Are you sure you know what a field is :cool:. I can't help but be a little curious about this one now.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top