Using form values for parameter for query

NikToo

Board Regular
Joined
Sep 24, 2015
Messages
66
Office Version
  1. 365
I'm stuck with something which doesn't make sense. I have a table of data and I've used a Crosstab query to rearrange it. I need to group things by years and periods, mainly Previous Year and Current Year, but I also want to make it easy to update, so I made a form with three text boxes: Current Year, Previous Year, Next Year. In my query I then made the following formula:

PY_P01: Sum(IIf([Year]=[Forms]![Years]![PreviousYear],[P01],0))

It looks like it should work. Just sum up the P01 column if the Year is the same as in the PreviousYear field in the form Years. Instead if get a message saying:

"The Microsoft database engine does not recognize '[Forms]![Years]![PreviousYear]' as a valid field name or expression."

If I change the form part to just say "2015" it works fine though. Odd.
 
Think I've sorted it, something to do with the Crosstab query. If I shonk it into a Make Table query and make query from that it seems to work. Oh well...
 
Upvote 0

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