如何对 DLOOKUP() 定义的字段启用过滤? [英] How to enable filtering on a field defined by DLOOKUP()?

查看:35
本文介绍了如何对 DLOOKUP() 定义的字段启用过滤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于表 T 的表单 TForm,设置为数据表.我的目标是向数据表添加一个可过滤的列,其中该列的值是使用另一列的值通过查询计算得出的.

I have a form TForm based on table T, set up as a datasheet. My goal is to add a filterable column to the datasheet where the column's value is calculated from a query using another column's value.

我尝试通过向 T 添加文本框 currentBox 来实现此目的.currentBox 的控件来源是:

I tried to do this by adding a text box currentBox to T. The control source for currentBox is:

=DLookUp("name","currentStatus","itemID=" & [ID])

其中 [ID]T 中的一个字段,currentStatus 是对 T 表的聚合查询> 相关.

where [ID] is a field in T and currentStatus is an aggregate query on a table that T is related to.

我可以过滤 TFormT 中的所有字段.但是我无法过滤 currentBox,即使它也显示为表单中的一列;点击列标题没有任何作用.

I can filter on all the fields in TForm that are in T. But I can't filter on currentBox, even though it also appears as a column in the form; clicking on the column header doesn't do anything.

我猜问题是 currentBox 没有绑定到 T 中的字段;有没有办法解决这个问题?

I'm guessing the problem is that currentBox is not bound to a field in T; is there a way to work around this?

推荐答案

我最终解决这个问题的方法是向 T 添加一个字段,并在 期间更新该字段AfterUpdate() 事件,带有来自 DLookup() 调用的值.由于该字段现在不再基于查询,因此可用于过滤表单.

The way that I ended up solving this was to add a field to T, and have that field updated during the AfterUpdate() event with the value from the DLookup() call. Because the field is now no longer query-based, it can be used to filter the form.

这篇关于如何对 DLOOKUP() 定义的字段启用过滤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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