update data on a table using list

S

Sensay

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.
 
J

Jason Rice

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top