Hi,
using a form I have been trying to get a list box to display the values of database table and have two options on there.
a) the user can select a list item and click a button to delete that item
b) the user can type text into a text box and click another button to add that value to the list box (and therefore the table sitting behind it)
i found a very useful starting point here http://www.thescripts.com/forum/thread634077.html
however, when i click to delete the item from the list, a Message box appears asking me to enter a parameter value. If the value entered is exactly the same as item chosen on the list then the item is removed, otherwise 0 items get removed. have i not done something right?
any help much appreciated,
Thanks hooijdonk
using a form I have been trying to get a list box to display the values of database table and have two options on there.
a) the user can select a list item and click a button to delete that item
b) the user can type text into a text box and click another button to add that value to the list box (and therefore the table sitting behind it)
i found a very useful starting point here http://www.thescripts.com/forum/thread634077.html
however, when i click to delete the item from the list, a Message box appears asking me to enter a parameter value. If the value entered is exactly the same as item chosen on the list then the item is removed, otherwise 0 items get removed. have i not done something right?
Code:
Private Sub cmdDelConsultant_Click()
On Error GoTo Err_cmdDelConsultant_Click
Dim strSQL As String
strSQL = "DELETE * " & _
"FROM [Consultant] " & _
"WHERE [Consultant]=" & [lstConsultant].Column(0)
DoCmd.RunSQL strSQL
Me![lstConsultant].Requery ' requery the list
Exit_cmdDelConsultant_Click:
Err_cmdDelConsultant_Click:
Exit Sub
MsgBox Err.Description
Resume Exit_cmdDelConsultant_Click
End Sub
Thanks hooijdonk
Comment