Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you took a look at the string you produced using <code>Debug.Print sqlstr</code> in code or <code>?sqlstr</code> from the command window you'd see</p> <pre><code>TRANSFORM Count([Deal Data ECM].[Disclosed Fees (Y/N)]) AS [CountOfDisclosed Fees (Y/N)]SELECT [Deal Data ECM].[Deal Type]FROM [Deal Data ECM]WHERE ((([Deal Data ECM].[Disclosed Fees (Y/N)]) = 'Y'))GROUP BY [Deal Data ECM].[Deal Type]PIVOT [Deal Data ECM].[Deal Region]; </code></pre> <p>Then you might notice there's no spaces between one clause and the next.</p> <p>adding returns where there are spaces makes it a little eaiser to see</p> <pre><code>TRANSFORM Count([Deal Data ECM].[Disclosed Fees (Y/N)]) AS [CountOfDisclosed Fees (Y/N)]SELECT [Deal Data ECM].[Deal Type]FROM [Deal Data ECM]WHERE ((([Deal Data ECM].[Disclosed Fees (Y/N)]) = 'Y'))GROUP BY [Deal Data ECM].[Deal Type]PIVOT [Deal Data ECM].[Deal Region]; </code></pre> <p>Try adding a space before each ending <code>"</code> </p> <pre><code>sqlstr = "TRANSFORM Count([Deal Data ECM].[Disclosed Fees (Y/N)]) AS [CountOfDisclosed Fees (Y/N)] " &amp; _ "SELECT [Deal Data ECM].[Deal Type] " &amp; _ "FROM [Deal Data ECM] " &amp; _ "WHERE ((([Deal Data ECM].[Disclosed Fees (Y/N)]) = 'Y')) " &amp; _ "GROUP BY [Deal Data ECM].[Deal Type] " &amp; _ "PIVOT [Deal Data ECM].[Deal Region]; " </code></pre> <p>However since you want to create a table you'll need to add a target. By adding an <code>INTO</code> clause between the select and from</p> <pre><code>sqlstr = "TRANSFORM Count([Deal Data ECM].[Disclosed Fees (Y/N)]) AS [CountOfDisclosed Fees (Y/N)] " &amp; _ "SELECT [Deal Data ECM].[Deal Type] " &amp; _ "INTO YourNewTable " &amp; _ "FROM [Deal Data ECM] " &amp; _ "WHERE ((([Deal Data ECM].[Disclosed Fees (Y/N)]) = 'Y')) " &amp; _ "GROUP BY [Deal Data ECM].[Deal Type] " &amp; _ "PIVOT [Deal Data ECM].[Deal Region]; " </code></pre> <p>Note: Everytime you execute this you'll be deleting the old table. Also note you should use <code>DoCmd.RunSQL</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload