vba 如何以相同的形式在数据表中显示查询结果?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5827047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 13:07:53  来源:igfitidea点击:

how to show query results in a datasheet in the same form?

ms-accessvba

提问by Ali

I have a Search form where you can input the criteria the user will be searching for. Then when I click the Search button, the query results will show in a separate form. What I want to happen is, show the the query results in the Search form. Does anyone know what I should do (step by step) and the code for it? Thanks!

我有一个搜索表单,您可以在其中输入用户将要搜索的条件。然后,当我单击“搜索”按钮时,查询结果将以单独的形式显示。我想要发生的是,在搜索表单中显示查询结果。有谁知道我应该做什么(一步一步)和它的代码?谢谢!

回答by HansUp

You can use Allen Browne's Search criteriaform example as the basis for your search form. He provides a sample databasein Access 2000 format and also a page which displays the code behind the form.

您可以使用 Allen Browne 的搜索条件表单示例作为搜索表单的基础。他提供了一个Access 2000 格式的示例数据库以及一个显示表单背后代码的页面。

Edit: You wanted your query results presented as a datasheet in the same form. AFAIK, there is no way to display your search control on a form in datasheet view. If a continuous form is acceptable, Mr. Browne's example should be easier for you to adapt. But if you must have the query results in datasheet view, you can add a subform (with its Default View property set to Datasheet) to the search form. However, that approach will require you to apply the filter to the subform rather than the main form.

编辑:您希望查询结果以相同的形式显示为数据表。AFAIK,无法在数据表视图中的表单上显示您的搜索控件。如果可以接受连续形式,布朗先生的例子应该更容易让你适应。但是,如果您必须在数据表视图中获得查询结果,您可以向搜索表单添加一个子表单(其默认视图属性设置为数据表)。但是,这种方法将要求您将过滤器应用于子表单而不是主表单。

回答by David-W-Fenton

If you really need a datasheet, you could embed it as a subform in an unbound form, and then put summary fields in the footer of the parent form. This would preserve the user's ability to take advantage of the features of datasheets (as opposed to the continuous form in the example from Allen Browne).

如果您确实需要数据表,则可以将其作为子表单嵌入到未绑定表单中,然后将汇总字段放在父表单的页脚中。这将保留用户利用数据表功能的能力(与 Allen Browne 示例中的连续形式相反)。