update data on a table using list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a list that contains data from a table.
i want the user to be able to rename those item or data by clicking on a
button.
that button should open a form containing the old item name ( selected from
the list) and a text box where he can write the new name.
how can i do that ?
and same thing if i want to delete an item ( from the list and form table)

thanks in advance
Sensay.
 
Hi Sensay,

In the On Open (or another appropriate event) you can use something like:

Dim i As Integer
Dim NewValue As String
For i = 0 To YourList.ListCount
If YourList.Selected(i) = True
Then YourTextBox1 = YourList.ItemData(i)
End If
Exit For
Next i

In the On Click Event of an "update" button (or another appropriate event)
you can use:

CurrentDb.Execute ("UPDATE YourListTable SET [YourFieldName] = " &
YourTextBox2 & ";")
Forms!YourOriginalForm.YourList.Requery

HTH
Jason
 
Back
Top