List Box NOT saving Records

yus786

I do OK
Local time
Today, 21:36
Joined
Jun 25, 2008
Messages
121
I have a list box with some items in it.

I have a command button that allows the user to save the items (once selected - can also multi select) like this:

list1.jpg


And this also saves to the table

However if i click on the list again - everything disappears and the record from the table is also removed - like this:

list2.jpg


Here is the code behind the cmdbutton

Code:
Dim SelectedVals
Dim item
Dim ctlList As Control

'List box is called List56

For Each item In List56.ItemsSelected
If SelectedVals > "" Then
SelectedVals = SelectedVals & ", " & List56.ItemData(item)
Else
SelectedVals = List56.ItemData(item)
End If
Next item

'Text Box is called Text59

Me!Text59 = SelectedVals

Set ctlList = Me!List56

ctlList.Requery
Can you please tell me what i've done wrong?

Thanks
 
what if you go to the next record (which would be a new one) after you click the button, does that work?
 
what if you go to the next record (which would be a new one) after you click the button, does that work?

Saved the current and went to the next record.

Upon going back and selecting the list - it does exactly the same.

So i can go to any record but clicking on the list just empty's the record
 
confirm whether Text59 is bound to field in the table
 
confirm whether Text59 is bound to field in the table

Yup - definitely bound. It does save it to the table, but if i click on the list(s) again - it then deletes it from the table and enters the new selection instead
 
instead of

Me!Text59 = SelectedVals

try this

if isnull(Me!Text59) or Me!Text59 = "" then
Me!Text59 = SelectedVals
else
endif
 
instead of

Me!Text59 = SelectedVals

try this

if isnull(Me!Text59) or Me!Text59 = "" then
Me!Text59 = SelectedVals
else
endif

This didn't work either but i found the issue.

list56 was bound. I made this unbound and now it saves.

Thanks again for you help
 
Cant understand how can it save data to table when it is unbound what were you trying to do
 

Users who are viewing this thread

Back
Top Bottom