使用Dlookup设置子表单多选字段 [英] Set subform multi-select field using Dlookup

查看:63
本文介绍了使用Dlookup设置子表单多选字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中有多个分配给一个流程的工作间,以及该流程的主要工作间的是/否字段.

I have a table that has multiple booths assigned to a process and a Yes/NO field for the primary booth for that process.

过程|展位|小学

Buff1 | 8 |不

Buff1 | 8 | No

Buff1 | 5 |是的

Buff1 | 5 | Yes

当使用Dlookup选择流程时,我正在尝试自动化表单以选择多选字段上的主要展位.

I am trying to automate a form to select the primary booth on a multiselect field when the process gets selected using Dlookup.

这是我正在使用的代码:

This is the code I am using:

Me.Booth.Value = DLookup("Booth", "BoothSource", "BoothSource.Process = '" & Me.Process & "' AND BoothSource.Primary = True")

展位"字段是一个多选字段.并且我收到错误3032尝试测试时无法执行此操作.请帮忙. 多选示例

The Booth field is a multi-select field. And I get error 3032 Cannot perform this operation when I try to test. Please help. Multi-Select Example

推荐答案

很难选择多选字段和组合框.

Multi-select fields and combo boxes are very hard to work with.

多值组合框的.Value属性显然是一个变量数组,并且是可写的.您可以将.Value属性设置为等于包含您的值的数组,而不只是包含您的值.

The .Value property of a multi-valued combo box is apparently a variant array, and writeable. You can set the .Value property equal to an array containing your value, instead of just your value.

请注意,即使不允许对列表进行值编辑,此操作也会绕过许多检查,例如Limit to list属性.您应该手动检查输入内容,因为这可能会导致错误.避免在数组中包括字符串以外的任何东西(数字,日期),因为它们不会触发错误,但是可以将Null中的任何内容插入列表中的某些项目以伪随机Unicode字符.

Note that this bypasses many checks, such as the Limit to list property, even if value edits to the list are disallowed. You should check your inputs manually, since this might cause errors. Avoid including anything other than a string in your array (numbers, dates), since these will not trigger an error, but insert anything from Null to some item on your list to pseudorandom unicode characters.

Dim varValue As Variant
varValue = DLookup("Booth", "BoothSource", "BoothSource.Process = '" & Me.Process & "' AND BoothSource.Primary = True")
Me.Booth.Value = Array(CStr(varValue))

请注意,我强烈建议您不要使用多选字段,以免造成麻烦.

Note that I strongly advice against using multi select fields, so you can avoid this mess.

这篇关于使用Dlookup设置子表单多选字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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