0

表单 onLoad 中的代码:

  country_combo.RowSourceType = "Value List"

重置函数中的代码:

  Dim lListIndex As Long

  With Me.country_combo
    For lListIndex = .ListCount - 1 To 0 Step -1
      .RemoveItem (lListIndex)
    Next lListIndex<br/>
  End With

填充国家组合的代码:

  *For n = 1 To numCountries*
    *countryCombo.AddItem (countryRS.Fields("countryName"))*
    *countryRS.MoveNext*
  *Next n*

在填充国家/地区组合框的代码运行后,我遇到了一个问题。这些值在那里,因为我可以运行 Debug.Print(countryCombo.Value) 并打印出所选国家/地区的名称,但我根本看不到组合框中的值。它们是不可见的,据我所知,特定项目没有可见性属性,除非我完全弄错了。

comboBoxError.png http://img110.imageshack.us/my.php?image=comboboxerror.png

4

3 回答 3

0

I think you should probably use Access's GUI tools to do what you're looking for. In design mode, click on the field you are trying to populate, then click the "lookup" tab. You can then specify a table to populate the field with and your forms should automaticly update as well.

于 2009-04-30T18:51:56.220 回答
0

我在使用 Access 2003 时遇到了类似的问题。基于对一个组合框的选择,列表框的行源设置为 SQL 字符串基本上是 SELECT DISTINCT [MyField_Selected] FROM MyTable。对于某些字段,值在列表框中可见,而其他字段则不可见。但是,这些值在那里,因为我可以通过代码访问它们。为了使它更有趣,它在 Access 2007 中运行良好。刚刚在另一个论坛上找到了解决方案。检查表格上相关字段的格式属性。就我而言,当 Access 2007 创建表时,它在其中放置了 @ 格式。我删除了它,一切都很好!

于 2010-04-12T13:45:54.627 回答
0

我还看到了您在此处描述的内容-据我所知,这是 Access 中的一个错误(我使用的是 2007 年),仅当您以编程方式弄乱组合框的内容时才会发生这种错误。它不会每次都发生。如果您突出显示组合框中的文本,该问题会自行纠正。

于 2009-05-11T04:20:27.233 回答