使用VBA代码将基于组合框中所选项目的表记录计数为条件 [英] count table records based on selected items in combo box as condition using VBA code

查看:66
本文介绍了使用VBA代码将基于组合框中所选项目的表记录计数为条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框,其中包含三个链接到表格中字段的项目。我想要的是在我选择组合框中的每个项目时计算总表记录。例如,当我选择雇用时在组合框中,将计算状态为Employed的所有记录。

I have a combo box with three items that link to the field in a table. What i want is to count the the total table records when i select each of the items in combo box. Example, when i select "Employed" in the combo box then all the records with the status Employed will be counted.

推荐答案

您将使用计数(*)来计算记录然后让WHERE子句根据您的选择过滤结果。例如,如果您的字段是EmployedStatus并且您的组合框在名为MyForm的表单上命名为MyCombo,则您的WHERE子句将如下所示:
You would use the Count(*) to count the records and then have the WHERE clause filter the results based on your selections. For example, if your field is EmployedStatus and your combo box was named MyCombo on a form named MyForm, your WHERE clause would look like this:
展开 | 选择 | 换行 | 行号


我是初学者,你可以更详细一点,如果你可以提供样本代码行会更好。谢谢
I am beginner with this, Could you be a little more detail of that, would be better if you can give lines of sample code with that. Thanks


要做到这一点,我需要你提供更多信息。您正在搜索的表的表结构是什么?组合框的行源是什么?您尝试了什么以及结果是什么?
To do that I need more information from you. What is the table structure for the table that you are searching in? What is the row source for the combo box? What have you tried and what were the results?


这篇关于使用VBA代码将基于组合框中所选项目的表记录计数为条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆