Question:
I have a form in Access VBA and five textboxes , but when i add the data in textboxes to Listbox it only add t?
Koketso Maseko
2014-06-16 23:29:24 UTC
this is my code

Listbox.addItem txtmajor.value
Listbox.addItem txttime.value
Listbox.addItem txtne.value
Listbox.addItem Comboesc.value
Listbox.addItem txtdesc.value
Four answers:
Blackened
2014-06-17 03:26:43 UTC
You're adding values to a multicolumn listbox so you need to add them like such:

Listbox.additem Cstr(txtmajor.value) & ";" & Cstr(txttime.value) & ";" ...etc, etc.



I usually do something as follows:



Private Sub AddItem_Click()

Dim addItems As Variant

addItems = Array(txtmajor.value, txttime.value, txtne.value, Comboesc.value, txtdesc.value)

listbox.Additem FixStr(addItems),0

End Sub



Function FixStr(items As Variant) As String

Dim i As Integer

For i = 0 To UBound(items)

FixStr = FixStr & CStr(items(i)) & ";"

Next i

End Function
Koketso Maseko
2014-06-17 09:55:27 UTC
Listbox.addItem txtmajor.text

Listbox.addItem txttime.text

Listbox.addItem txtne.text

Listbox.addItem Comboesc.text

Listbox.addItem txtdesc.text



with this code i get this Error
K-SiS
2014-06-17 06:42:47 UTC
Listbox.addItem txtmajor.text

Listbox.addItem txttime.text

Listbox.addItem txtne.text

Listbox.addItem Comboesc.text

Listbox.addItem txtdesc.text
Strider
2014-06-17 06:43:43 UTC
From your code, it the items you are adding from your controls will be added only to "Listbox"...



I mean 1 listbox only. ^_^


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...