unbound list box

kes

Registered User.
Local time
Today, 17:17
Joined
Mar 6, 2013
Messages
53
hi,

I have 2 list box. one bound to a table and one unbound presenting the values that i added to the table.
i have an add button that add the values to the table and the unbound list to present them.
I'm having trouble with the remove button. I want the button to remove the item from list2(the unbound one) and from the table itself.

can you help?
thanks!
 

Attachments

  • Capture.PNG
    Capture.PNG
    37.8 KB · Views: 98
What do you not bound both list controls to tables, it is much easier?
Table name is "IDCopy", field name is "IDCopy" - number value
Button names are "AddToListe" and "AddFromListe"
List names are "CopyToListe" and "CopyFromListe"

Code:
Private Sub AddToListe_Click()
  DoCmd.SetWarnings False
  'If number value
  DoCmd.RunSQL ("Insert into IDCopy  (IDCopy) VALUES (" & Me.CopyFromListe & ")")
  'If string value
  'DoCmd.RunSQL ("Insert into IDCopy  (IDCopy) VALUES ('" & Me.CopyFromListe & "')")
  Me.CopyToListe.Requery
  DoCmd.SetWarnings True
End Sub
 
Private Sub RemoveFromListe_Click()
  DoCmd.SetWarnings False
  'If number value
  DoCmd.RunSQL ("Delete * From IDCopy Where [IDCopy] =" & Me.CopyToListe & "")
  'If string value
  'DoCmd.RunSQL ("Delete * From IDCopy Where [IDCopy] ='" & Me.CopyToListe & "'")
  Me.CopyToListe.Requery
  DoCmd.SetWarnings True
End Sub
 
I've done simething similar. Works great. Thanks!
 

Users who are viewing this thread

Back
Top Bottom