我有一个带有字符串类型字段的表(即表字段参数中的多值组合框)。
表格中多值字段设置
我需要使用此表中单独记录集的值自动填充表单(基于此表)中的新记录。
使用通常的文本字段和具有单一选择的组合框就可以了。它有效。
常用文本字段和组合框的代码
如何自动填充多值组合框?我怎样才能检测到该控件是多值组合框?
我会使用“ColumnCount”来表示 ctrl 有多个或没有。
'Check Multi or Single
Private Sub Combo1_Click()
If Me.Combo1.ColumnCount > 1 Then
MsgBox "Multi"
Else
MsgBox "Single"
End If
End Sub
然后使用如下 SQL 从所选值中提取值。 :)
' Get the selected value from the ComboBox
selectedValue = Me.ComboBox1.Value
' Create a SQL query to retrieve all columns for the selected item
strSQL = "SELECT * FROM YourTableOrQuery WHERE IDField = " & selectedValue