vba - Updating an Access Query definition (SQL) and reflecting in dependent queries
问题描述
I am still relatively new to Access and the functionality, but bottom line is I have a query (called ScenarioQuery), which pulls data from a table ScenarioDetails and creates columns which are equivalent to fiscal periods, so each column will be a calculated column like
IIf(MonthNumber = 1, [Value], 0) AS [S2020Jan]
What I am trying to do is use VBA to dynamically update the year as part of the column aliases as each "scenario" will contain a different year range.
I have successfully set up the macros to update the years dynamically through using arrays and recordsets, however, I have linked (dependent) queries which reference the field names in their own result sets and these don't update automatically when a query def is updated (at least as far as I know)
Is there a way to accomplish this dependency chain update? Or would I either have to write further macros to update these queries / alter the objects to pull from another source ?
解决方案
像这样使用QueryDefs
集合
For Each q In CurrentDb.QueryDefs
q.SQL = Replace(q.SQL, "2020", "2021")
Next q
推荐阅读
- html - 与容器相邻的具有渐变下一个的 CSS 形状
- html - 两个单独的 div 上的连续渐变
- javascript - 我的图像在旋转时没有占据画布的整个宽度
- javascript - HTTP拦截器使用离子/角度导致CORS问题
- r - 将字符串拆分为单个字符,计算每个字符出现的次数,然后组合成单个 df/matrix
- php - WooCommerce 产品自定义循环由一系列 SKU 过滤
- amazon-s3 - 使用 Helm 在 Spinnaker 上配置 S3
- angular - 无法在 Angular 10 中处理 HttpClient
- postgresql - Citus PostgresQL 需要注意哪些设置
- citus - 将数据同步到插入时离线的节点(Citus)