组合框代码返回错误消息!!!

问题描述:

我以为我昨天弄清楚了。错误!我有2个组合框,CBUnit和CBSub。当在CBUnit中单击值时,它应该在CBSub中显示相应的子值。这些组合框基于2个表格; tbl_Unit和tbl_Sub。


CBUnit具有以下内容:

RowSource:tbl_Unit

ColumnCount:2

ColumnWidth:0&quot ;; 1.5"

BoundColumn:1

CBSub具有以下内容:

RowSource:SELECT tbl_Sub。 AUTONUMBER,tbl_Sub.Sub FROM tbl_Sub ORDER BY [Sub];

ColumnCount:2

ColumnWidth:0&quot ;; 1"

BoundColumn:1


In theVisual Basic Editor,我输入以下代码:

I thought I had it figured out yesterday. WRONG! I have 2 combo boxes, CBUnit and CBSub. When value is clicked within CBUnit, it should bring up corresponding sub-values in CBSub. These combo boxes are based on 2 tables; tbl_Unit and tbl_Sub.

CBUnit has the following:
RowSource: tbl_Unit
ColumnCount: 2
ColumnWidth: 0";1.5"
BoundColumn: 1

CBSub has the following:
RowSource: SELECT tbl_Sub.AUTONUMBER, tbl_Sub.Sub FROM tbl_Sub ORDER BY [Sub];
ColumnCount: 2
ColumnWidth: 0";1"
BoundColumn: 1

In theVisual Basic Editor, I put the following code:

展开 | 选择 | Wrap | 行号

嗯,你的组合框命名为CBUnit ,但在WHERE中没有提到:

" WHERE [UnitID] =" &安培;我!单位

您是否尝试使用:

" WHERE [UnitID] =" &安培;我!CBUnit


还要确保UnitID是数字!


Nic; o)
Hmm, your combobox is named CBUnit, but not referred to in the WHERE:
"WHERE [UnitID]=" & Me!Unit
Did you try to use:
"WHERE [UnitID]=" & Me!CBUnit

Also make sure that the UnitID is numeric !

Nic;o)



嗯,你的组合框命名为CBUnit,但在WHERE中没有提到:

" WHERE [UnitID] =" &安培;我!单位

您是否尝试使用:

" WHERE [UnitID] =" &安培;我!CBUnit


还要确保UnitID是数字!


Nic; o)
Hmm, your combobox is named CBUnit, but not referred to in the WHERE:
"WHERE [UnitID]=" & Me!Unit
Did you try to use:
"WHERE [UnitID]=" & Me!CBUnit

Also make sure that the UnitID is numeric !

Nic;o)



废话,我认为这样可行。但我替换它并显示相同的错误消息。我确实检查了UnitID是否为数字。它是。自动编号和长整数。


其他任何想法?


但感谢至少试图帮助Nic。我非常感激!

Crap, I thought that would work. But I replaced it and it displayed the same error message. And I did check to see if UnitID is numeric. It is. Autonumber and Long Integer.

Any other ideas?

But thanks for at least trying to help Nic. I appreciate it greatly!


Deanndra,


不只是你的代码错误地引用了它。

但是,从我的错误消息读取中,表tbl_Sub中的字段[Sub]不存在。您可以发布该表的表元数据,我们可以为您检查。以下是如何发布表MetaData的示例:
表名= tblStudent
Deanndra,

It''s not just that bit of your code that referred to it wrongly.
However, from my reading of your error message, it is the field [Sub] in the table tbl_Sub that doesn''t exist. Can you post your table meta-data for that table and we can check it over for you. Here is an example of how to post table MetaData :
Table Name=tblStudent
展开 | 选择 | Wrap | 行号