gpt4 book ai didi

vba - 在表单 Access vba中将多列值添加到列表框

转载 作者:行者123 更新时间:2023-12-02 02:10:27 27 4
gpt4 key购买 nike

我在向 Access 列表框中的多个列添加值时遇到问题。我尝试过这样的解决方案:Adding items in a Listbox with multiple columns这是:vba listbox multicolumn add [duplicate] ,但它不起作用。在我的例子中,列表框没有属性“List”。我有编译错误:

enter image description here

Private Sub cmdAddPosition_Click()

Dim i As Integer

Me.lstAddPositions.ColumnCount = 7

If Me.txtAddPos.Value = i And i > 0 And i < 50 Then
Me.lstAddPositions.AddItem (Me.txtAddPos.Value)
'Me.lstAddPositions.AddItem(Me.txtAddPos.Value,(i))
Me.lstAddPositions.List(0, i) = Me.txtAddPos.Value
'Me.lstAddPositions.Column(0, i) = Me.txtAddPos.Value 'adding number of position
'Me.lstAddPositions.Column(2, i) = Me.lstAddHidden.Column(0, 0) 'adding titel
End If

Me.lstAddPositions.Requery

End Sub

遇到这种情况我能做什么?

最佳答案

下面是在行源是值列表的情况下向 Access 表单上的多列非绑定(bind)列表框添加项目的示例。您必须通过创建一个放置在值列表中的字符串来添加它。

Private Sub cmdAddPosition_Click()
Dim i As Integer

Me.lstAddPositions.ColumnCount = 7

If Me.txtAddPos.Value = i And i > 0 And i < 50 Then
Me.lstAddPositions.AddItem "Col1" & "," & "col2" & "," & "Col3" & "," & _
"Col4" & "," & "Col5" & "," & "col6" & "," & "col7" &";"
End If

Me.lstAddPositions.Requery
End Sub

关于vba - 在表单 Access vba中将多列值添加到列表框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18870600/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com