Access 2010中的明显错误:组合框产生NULL结果 [英] Apparent bug in Access 2010: Combo box produces a NULL result

查看:173
本文介绍了Access 2010中的明显错误:组合框产生NULL结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


软件:Access 2010

Software: Access 2010


问题:引用一个宏到组合框列通过[Forms]![Form_Name]![ComboBox_Name]。[Column](0)产生一个NULL返回。它不会在任何时候发生:在我的表单中的四个组合框中,只有两个表现出这种行为。另外两个组合框
将合法值返回到某一行 - 一个从第204行开始返回NULL,另一个从第8行开始向上返回。所有四个框都是从数据库表加载值,每个数据库表包含两个字段的查找记录,如
< indexfield>< valuefield>。所有四个框都有行源类型:表/查询和行源定义如下查询:

Problem: a reference in a macro to combo box column via [Forms]![Form_Name]![ComboBox_Name].[Column](0) produces a NULL return. It does not happen any time: out of four combo boxes on my form only two showed this kind of behavior. The other two combo boxes were returning legitimate values up to a certain line - one was returning NULL starting from line 204 and up, another  - starting from line 8 and up. All four boxes are loading values from database tables, each containing two-fields lookup records like <indexfield><valuefield>. All four boxes had Row Source Type: Table/Query and Row Source defined with a query like the following:

SELECT dbo_TABLENAME.INDEXFIELDNAME,dbo_TABLENAME.VALUEFIELDNAME

FROM dbo_TABLENAME

ORDER BY dbo_TABLENAME.VALUEFIELDNAME;

SELECT dbo_TABLENAME.INDEXFIELDNAME, dbo_TABLENAME.VALUEFIELDNAME
FROM dbo_TABLENAME
ORDER BY dbo_TABLENAME.VALUEFIELDNAME;

经过长时间的试错和搜索后,我可以通过更改ORDER BY来完全消除NULL返回。 dbo_TABLENAME.VALUEFIELDNAME 到dbo_TABLENAME..INDEXFIELDNAME,但这个解决方案并不令人满意,因为我需要按字母顺序排序的组合框中的值
。创建表的方式是索引当前对应于按字母顺序排序的值,但是当新值将添加到表中时,此顺序将无法维持。

After a long trial and error search I was able to eliminate the NULL returns completely by changing the ORDER BY from  dbo_TABLENAME.VALUEFIELDNAME  to dbo_TABLENAME..INDEXFIELDNAME, yet this solution was not satisfactory as I need the values in the combo boxes sorted alphabetically. The tables were created the way that the indices currently correspond to the values sorted alphabetically, yet when new values will be added to the tables this order will not be sustained.

解决方法:我已替换了  ;   [Forms]![Form_Name]![ComboBox_Name]。[Column](0)  with 

Workaround: I have replaced  [Forms]![Form_Name]![ComboBox_Name].[Column](0)  with 

DLookUp(" INDEXFIELDNAME"," dbo_TABLENAME"," ; VALUEFIELDNAME ='"& [Forms]![ Form_Name]![ComboBox_Name]

DLookUp ("INDEXFIELDNAME", "dbo_TABLENAME", "VALUEFIELDNAME = '" & [Forms]![Form_Name]![ComboBox_Name])

< span style ="line-height:20px">之后我能够将
ORDER BY返回  &NBSP; dbo_TA BLENAME..INDEXFIELDNAME。

and after that I was able to return the ORDER BY  back to  dbo_TABLENAME..INDEXFIELDNAME.


推荐答案

一些疯狂的想法:

Some wild ideas:

*属性不应该包含在[]中,所以请尝试:

[Forms]![Form_Name]![ComboBox_Name] .Column(0)

* Properties should not be wrapped in [ ], so try:
[Forms]![Form_Name]![ComboBox_Name].Column(0)

*检查是否ColumnCount属性与RowSource中的列数相匹配。

* Check if the ColumnCount property matches the number of columns in the RowSource.


这篇关于Access 2010中的明显错误:组合框产生NULL结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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