【发布时间】:2016-06-27 14:37:04
【问题描述】:
提前感谢您抽出宝贵时间帮助我。这是我第一次在这里提出问题——因为我在研究现有问题和答案方面取得了巨大成功!我是这个网站的忠实粉丝!
无论如何 - 切中要害。我编写了一个程序,其中包括用户表单中使用的一些列表框。我从一个从查询 Oracle 数据库的 SQL 语句派生的数组中填充这些多列列表框。当查询结果中的记录满足特定条件时,该记录会在列表框中为最终用户发布。
问题:当查询中只有一条记录满足条件时,这些列被包装成多行而不是一行。当用户单击一行时,这会导致我打算发生的事情出现问题。我需要将查询中与单个记录关联的所有列仅写入列表框的一行 - 即使只有一条记录。有趣的是:当返回 2 条或更多记录时,它会发布到列表框。
感谢您的帮助!我已经用尽了我的在线搜索,还没有发现这样的常见问题。
这是我的一些代码:
.ConnectionString = strDBConnectWrite 'Connect to database
.CursorLocation = adUseClient 'Necessary for creating disconnected recordset
.Open 'Open Connection
End With
With oTbl4
.ActiveConnection = oDB
.source = strSQL4 'SQL statement above
.LockType = adLockReadOnly
.Open
'Populate the array with the recordset
oArray4 = .GetRows
k = .Fields.Count
End With
x = oTbl4.RecordCount 'for debugging purposes during development
'Debug.Print "oTbl4 count" & x
With frmValidationForm.listAddresses 'listbox to which I want to publish the query results
.ColumnCount = 8
.ColumnWidths = "100;0;0;0;0;0;0;0"
.Clear 'Clears the listbox
.BoundColumn = 1
.List = Application.Transpose(oArray4)
.ListIndex = -1
End With
【问题讨论】: