Multi-Select Listbox & Update

mea99sdp

Registered User.
Local time
Today, 20:47
Joined
Jun 18, 2007
Messages
18
Hi

I have a list box called listSNRT on a form, with a button at the side, when I press the button all selected values in the listbox updates. The listbox has a column called completed, which is yes/no. When I press the button I need the column value to change from no to yes.

Now how do i code the button to update the values?

Cheers
 
M,

Need more info here.

If the underlying data is updated, shouldn't it be as simple as ReQuerying
the listbox?

Wayne
 
hi wayne

i have not coded the button yet, i'm finding it difficult, this os what i got behind the button

Dim i As Variant
For Each i In ListSNRT.ItemsSelected

'this is the bit i'm find hard, currently all items in the list have no for completed, i need them to be changed to yes

Next i
Me.ListSNRT.Requery

hope this helps
 
M,

Something like this:

Code:
Dim i As Long
For i = 0 To Me.ListSNRT.ListCount - 1
   If Me.ListSNRT.Selected(i) Then
      DoCmd.RunSQL "Update YourTable " & _                          <-- Your Table Name
                   "Set    TheFlag = -1 " & _                       <-- Your Flag Field
                   "Where  YourKey = " & Me.ListSNRT.ITemData(i, 0) <-- Your Primary Key, 
                                                                        index starts at 0 (Column 1)
   End If
   Next i
Me.ListSNRT.Requery

Wayne
 

Users who are viewing this thread

Back
Top Bottom