ms访问复选框 [英] ms access check box

查看:45
本文介绍了ms访问复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表格,显示公司. 在表单中创建了组合框以列出该公司的所有产品 每个项目旁边都有一个复选框*(在组合框中).如何仅对已检查的项目创建报告,

I created a form, displaying company. created combo-box in the form to list all products of that company with a check-box next to each item*(IN THE COMBO BOX). how do I create a report on only the items that were checked,

或 soloution2,我尝试在子数据表中的表格上显示该公司的所有产品,并带有一个复选框.如何仅对已检查的项目创建报告,

OR soloution2, I tried showing all products of that company on that form in sub-data-sheet, with a checked box field. how do I create a report on only the items that were checked,

不是很精通访问... 谢谢MIL

not very proficient in access... thanks a MIL

推荐答案

本文 ,Microsoft显示了如何从列表框中以字符串的形式检索值.然后可以将其用于为Openargs创建SQL语句(取决于Access的版本),也可以将其用作报告的WHERE参数:

In this article, Microsoft shows how to retrieve the values from a listbox as a string. This can then be used to create an SQL statement, for Openargs (depending on your version of Access) or as the WHERE argument for the report:

 DoCmd.OpenReport "ReportName",acViewPreview,,"ID IN (" & ListOfIDs & ")"

请注意,您需要用引号引起来的字符串列表:

Note that you will need quotes for a list of strings:

 "A","List","Of","Strings"

但不包括数字:

 1,2,3,4 

这与子表单类似,但是最好的选择是构建sql语句并将其用作记录源:

This would be similar for the subform, but the best bet would be to build the sql statement and to use that as the Record Source:

 strSQL="SELECT ID, SomeField FROM SomeTable WHERE ID IN (" & ListOfIDs & ")"
 Me.[NameOfSubformControl].Form.RecordSource=strSQL 

您可能想使用命令按钮来执行此操作. 请确保使用子窗体控件的名称,而不要使用包含的窗体. 使用仅允许选择一个公司的简单列表框会更容易,因为您可以为子窗体控件设置链接子级"(到公司ID)和链接主目录"(列表框的名称)字段.

You might like to use a command button to do this. Be sure to use the name of the subform control, not the the form contained. It would be easier with a simple listbox that allowed only one company to be selected, because you could then set the Link Child (to the company ID) and Link Master (name of the listbox) fields for the subform control.

在两种情况下,最好都将列表框设置为两列,分别为Company ID和Company Name,并将Company ID作为隐藏的绑定列.

In both cases, it is best that the listbox is setup with two columns, Company ID and Company Name, with Company ID as the hidden, bound column.

这篇关于ms访问复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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