访问表单字段逻辑
我正在尝试有条件地仅显示满足特定条件的行,请允许我在继续之前向您提供一些背景信息:
我创建了一个 Access 表单并将其链接到我的计算机上的测试数据库。我感兴趣的特定表包含以下(重要)行:
ID 、 Office、Name、SecurityNumber
问题是, ID 不是唯一的。有两个办公室位置,每个办公室都有自己的一组唯一 ID 号。这意味着这里和那里的 ID 10 可能是同一个人,也可能不是同一个人。 (此数据来自我们尚不打算更改的旧安全系统,因此我无法更改它)
但是 ID 对于每个办公室来说都是唯一的。
所以!我用 TABS 创建了一个 Access 表单!两个选项卡,每个办公室一个。我现在想要实现的是:
让每个选项卡的 ID/Name/SecurityNumber 字段仅填充与其特定“Office”值匹配的行。
感谢您的阅读并感谢您的帮助! :D
I'm trying to make access conditionally only show rows that meet a certain condition, allow me to give you some background info before I proceed :
I've created an Access form and linked it to a test DB on my machine. The particular table I am interested in contains the following (important) rows :
ID , Office, Name, SecurityNumber
The thing is, ID is not unique. There are two Office locations, and each Office has it's own set of unique ID numbers. This means that ID 10 here and there may or may not be the same person. (this data comes out of a legacy security system we're not looking to change yet, so I cannot change it)
But ID -is- unique to each Office.
SO! I created an Access form with TABS! Two tabs, one for each office. What I am trying to achieve now is :
Have the ID/Name/SecurityNumber fields for each tab populate with only rows that match it's particular 'Office' value.
Thank you for reading and thank you for helping! :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望在单独的选项卡页控件中显示办公地点的数据,则可以在页面上使用子表单,这些子表单的不同之处仅在于用作其记录源的查询的 WHERE 子句。因此,对于 Office1 子表单,查询可以是:
那么对于 Office2,查询将是相同的,除了 WHERE 子句:
据我了解您的问题,该方法将满足您的要求。
然而,这并不是真正简单的“访问方式”。相反,请考虑使用组合框控件来允许用户选择他们想要查看的办公室。在组合的更新后事件的代码中,修改用作表单记录源的 SELECT 语句或创建过滤器表达式并应用它。
另外,由于您是从 SQL Server 提取表单数据,因此请考虑是否希望表单加载所选办公地点的每条记录。如果每个位置只有几到中等数量的行,那么可能不会太担心,但如果您要处理数千行,则可能会如此。一般来说,您应该尽量避免通过网络提取大量数据;相反,要谨慎地拉……只拉当前任务所需的东西。
If you want the data for the office locations presented in separate tab page controls, you could use subforms on the pages which differ only in the WHERE clause of the queries used as their record sources. So for the Office1 subform, the query could be:
Then for Office2, the query would be the same except for the WHERE clause:
As I understand your question, that approach would do what you're asking for.
However, that's not really the easy "Access way" to do it. Instead consider a combo box control to allow your users to choose which office they want to view. In the code for the combo's after update event, either modify the SELECT statement used as the form's record source or create a filter expression an apply it.
Also, since you're pulling the form's data from SQL Server, consider whether you want your form to load every record for the selected office location. It may not be much concern if you have only a few to moderate number of rows for each location, but if you'll be dealing with multiple thousands of rows it could be. In general, you should try to avoid pulling copious amounts of data across the wire; pull sparingly instead ... only what you need for the immediate task at hand.