根据表单中选择的字段构建查询 [英] Building Query based on fields selected in a form
本文介绍了根据表单中选择的字段构建查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我最近的任务是接管一堆我没有创建的Access数据库。我的VBA技能很难说最好,但我有一个特别的问题,我正在努力。我想要做的是使用一个表单来识别将通过查询并生成拆分字段的Excel文档的多个值。我已经有了代码,但我需要添加一个列选择。要添加的工具或
Hi Everyone, I have recently been tasked with taking over a bunch of Access databases that I didn''t create. My VBA skills are weak to say the best but I have a particular problem I am working on. What I want to do is use a form to identify multiple value that will pass through a query and generate excel documents for a split field. I already have the code for that but I need to add a "column selection" tool to add or
展开 | 选择 | Wrap | 行号
推荐答案
- 根据我的收集,您决定包含/省略查询中的列是由一系列复选框决定的。基于此,我们假设我们有一个名为Table1的表,其中包含三个字段:
- From what I can gather, your decision to include/omit Columns from a Query is determined by a series of Check Boxes. Based on this, let''s assume we have a Table named Table1 with three Fields:
- [First] {TEXT}
- [MI] {TEXT}
- [Last] {TEXT}
- 循环通过表单上的所有控件。
- 如果控件是复选框并且已选中,将开始构建SQL语句。
- 一旦处理了表单上的所有控件,将修剪SQL语句并构建Final Statement并将其分配给Variable strSQLFinal。
- 如果没有选中Check Box,则代码无害地存在。
展开 | 选择 | Wrap | 行号
感谢您的快速回复。我试图弄清楚你之前曾帮助过某个人的帖子,但却无法确切知道这会发生什么。我在哪里声明尺寸是否重要?此外,表单有4个文本框,也通过查询传递变量。所以我不确定这将如何添加到我现有的代码中:
Thanks for the quick response. I was trying to make sense of a previous post that you had helped someone with but can''t figure out exactly where this would go. Does it matter where I declare the dimensions? Also, the form has 4 text boxes that also pass variables through the query. so I''m not sure how this would be added to my existing code:
展开 | 选择 | Wrap | 行号
- 构建逗号分隔的字符串(第7行到第15行)并将其传递给函数(第22行):
- Build a Comma Delimited String (Lines 7 to 15) and pass it to a Function (Line 22):
展开 | 选择 | Wrap | 行号
这篇关于根据表单中选择的字段构建查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文