M
March
Hello,
I have a question about how to addItem in List box (Access) using VBA.
I have one combo box and one list box. The values in the list box will
change when the value in combo box changes.
I try the code below:
Dim rst As DAO.Recordset
Dim db As DAO.Database
If Me.ComboBox = "A" Then
sqlCmd = "SELECT A FROM TableName;"
Set rst = db.OpenRecordset(sqlCmd)
Do Until rst.EOF
If Not IsNull(rst!A) Then
With Me.ListBox
.RowSource = vbNullString
.AddItem rst!A
End With
End If
rst.MoveNext
Loop
TableName contains field "A" that I need all records in "A" show in the
List Box. I also need to use list box array.
I have a question about how to addItem in List box (Access) using VBA.
I have one combo box and one list box. The values in the list box will
change when the value in combo box changes.
I try the code below:
Dim rst As DAO.Recordset
Dim db As DAO.Database
If Me.ComboBox = "A" Then
sqlCmd = "SELECT A FROM TableName;"
Set rst = db.OpenRecordset(sqlCmd)
Do Until rst.EOF
If Not IsNull(rst!A) Then
With Me.ListBox
.RowSource = vbNullString
.AddItem rst!A
End With
End If
rst.MoveNext
Loop
TableName contains field "A" that I need all records in "A" show in the
List Box. I also need to use list box array.