I have a page in a multi page form which takes input from a text box and check box and adds this into a multi column list box below it when a submit button I clicked. I then want the user to be able to select a row in the list box and display the contents in the text box and check box for editing.
I can add multiple text box and check box values into the list box using the submit button, but it does not select a row when I click on the list box item. It just does nothing. It looks like the focus is not being transferred.
Would really appreciate it if someone could give me some ideas or guidance on how I may solve this? The code for the two actions are:
Private Sub cmdaddcontrol_Click()
If Not txtbox_Ctrl_Desc = "" Then 'check for input into text box
ctrl_listbox.AddItem 'add items to list box
ctrl_listbox.List(ctrl_list_count, 0) = ctrl_list_count + 1 'add row number in list box column
ctrl_listbox.List(ctrl_list_count, 1) = txtbox_Ctrl_Desc.Value 'set list box column to text box contents
If Not chkbox_ctrl = False Then 'check if check box is selected then insert appropriate value into listbox column
ctrl_listbox.List(ctrl_list_count, 2) = "Y"
Else
ctrl_listbox.List(ctrl_list_count, 2) = "N"
End If
ctrl_list_count = ctrl_list_count + 1 'increment listbox row counter
txtbox_Ctrl_Desc = "" 'reset text box to blank
chkbox_ctrl = False 'reset check box to blank
Else
MsgBox "You have not enetered anything in the control box" 'error message if no control description in text box
End If
End Sub
Private Sub ctrl_listbox_Click()
Dim i As Integer
'find the selected list item
i = ctrl_listbox.ListIndex
ctrl_listbox.Selected(i) = True
'add the values to the text and check boxes above the list box
txtbox_Ctrl_Desc.Value = ctrl_listbox.Column(1, i)
If Not ctrl_listbox.Column(3, i) = " Y" Then
chkbox_ctrl.Value = True
Else
chkbox_ctrl.Value = False
End If
End Sub