Hello,
I'm trying to filter and print a report using a button on a form, I can get it to work, however I seem to be a little bit short for my ideal filter. I can get the following to work (with 15 criteria):
However I want to add a 16th criteria and I have tried various bits, I though this would be successful but it hasn't. It might be that I use a query, but I'd prefer not to as I can use my form with various filters from VBA buttons, or maybe I just accept that 15 is all I can have?
This is what I thought would work:
The error message that I get returned it Compile error: Syntax error
Any advice would be appreciated.
Many thanks
Malcolm
I'm trying to filter and print a report using a button on a form, I can get it to work, however I seem to be a little bit short for my ideal filter. I can get the following to work (with 15 criteria):
Code:
DoCmd.OpenReport "rptBuyingList", acViewReport, , "STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat1 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat2 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat3 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat4 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat5 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat6 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat7 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat8 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat9 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat10 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat11 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat12 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat13 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat14 Or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat15", acHidden
However I want to add a 16th criteria and I have tried various bits, I though this would be successful but it hasn't. It might be that I use a query, but I'd prefer not to as I can use my form with various filters from VBA buttons, or maybe I just accept that 15 is all I can have?
This is what I thought would work:
Code:
DoCmd.OpenReport "rptBuyingList", acViewReport, , "STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat1 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat2 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat3 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat4 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat5 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat6 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat7 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat8 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat9 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat10 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat11 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat12 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat13 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat14 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat15 _
or STOCK_CAT = Forms!frmBackground!subfrmBuyingList!txtBLCat16", acHidden
The error message that I get returned it Compile error: Syntax error
Any advice would be appreciated.
Many thanks
Malcolm