基于值列表访问列表框 - 按列排序

发布于 2024-12-09 19:44:38 字数 300 浏览 0 评论 0原文

我有一个访问表单上有 3 列的列表框,它具有作为行源的值列表(不是来自数据库的记录集),该列表作为逗号分隔的字符串传递。第三列是一个数值,我希望对第三列上的列表框 desc 进行排序。

行源如下所示:

0,Standard price,1650,
14,Bookings made during Oct 2011,3770,
15,Minimum Stay 4 Nights - Special Price,2460

列表框正确填充。我只是不知道在这种情况下如何按第三列对列表框进行排序。有什么想法吗?

I have a Listbox with 3 columns on an access form which has as it's row source a value list (not a recordset from the db), which is passed as comma seperated string. The third column is a numeric value, and I wish to sort the listbox desc on that third column.

The rowsource looks like this:

0,Standard price,1650,
14,Bookings made during Oct 2011,3770,
15,Minimum Stay 4 Nights - Special Price,2460

The listbox populates correctly. I just have no idea how to sort the listbox by the third column in this case. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若无相欠,怎会相见 2024-12-16 19:44:38

使用断开连接的记录集的一个非常粗略的想法:

Dim rs As New ADODB.Recordset

slist = "0,Standard price,1650," _
& "14,Bookings made during Oct 2011,3770," _
& "15,Minimum Stay 4 Nights - Special Price,2460"

With rs
  .ActiveConnection = Nothing
  .CursorLocation = adUseClient
  .CursorType = adOpenStatic
  .LockType = adLockBatchOptimistic
  With .Fields
    .Append "Field1", adInteger
    .Append "Field2", adVarChar, 200
    .Append "Field3", adInteger
  End With
  .Open


  ary = Split(slist, ",")

  For j = 0 To UBound(ary)
      .AddNew
      For i = 0 To 2
          .Fields(i).Value = ary(j)
          j = j + 1
      Next
      j = j - 1

  Next

  .Sort = "Field3"
End With

slist = rs.GetString(, , ",", ",")
slist = Left(slist, Len(slist) - 1)

A very rough idea using disconnected recordset:

Dim rs As New ADODB.Recordset

slist = "0,Standard price,1650," _
& "14,Bookings made during Oct 2011,3770," _
& "15,Minimum Stay 4 Nights - Special Price,2460"

With rs
  .ActiveConnection = Nothing
  .CursorLocation = adUseClient
  .CursorType = adOpenStatic
  .LockType = adLockBatchOptimistic
  With .Fields
    .Append "Field1", adInteger
    .Append "Field2", adVarChar, 200
    .Append "Field3", adInteger
  End With
  .Open


  ary = Split(slist, ",")

  For j = 0 To UBound(ary)
      .AddNew
      For i = 0 To 2
          .Fields(i).Value = ary(j)
          j = j + 1
      Next
      j = j - 1

  Next

  .Sort = "Field3"
End With

slist = rs.GetString(, , ",", ",")
slist = Left(slist, Len(slist) - 1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文