Hi
I appreciate your help in advance. I'm new to VBA - and would like to know how to add and remove items from a listbox (not the main table) via a subform instantly.
1. Code to populate listbox (listObjects):
Private Sub listObjects_Click()
DoCmd.OpenForm "frm_CSPerformance", , , "ID = " & Me.listObjects.Column(0, Me.listObjects.ListIndex + 1)
End Sub (Works)
2. Subform Comand Button: Changes the status of a textbox (listFollowup)to "yes or no" in the mainform (CS_Performance), instantly. This means a individual needs to follow-up or not, on a part. I would also like this command button on the subform to add items to the listbox if the listFollowup is "yes" and remove items from listbox if the listfollowup is "no" in mainform (CS_Performance), instantly:
Current Code:
Private Sub cmbFollowup_Click()
On Error GoTo Err_cmbFollowup_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frm_CSPerformance.listFollowup.SetFocus
Forms!frm_CSPerformance!listFollowup.Value = "Yes"
'add item to listbox ??
listObjects.RowSource = listObjects.RowSource & ";"
Set rstSubFormClone = Nothing
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
Exit_cmbFollowup_Click:
Exit Sub
Err_cmbFollowup_Click:
MsgBox Err.Description
Resume Exit_cmbFollowup_Click
End Sub
I also tried adding and removing items for the listbox via "on change" command on the listfollowup test box - it didn't work either.
code:
Private Sub listFollowup_Change()
Me.listFollowup.Value = "Yes"
MyList.RowSource = MyList.RowSource & MyText & ";"
Me.listObjects.Requery
Me.listFollowup.Value = "No"
Me.listObjects.Value = Me.listObjects.Column(0, Me.listObjects.ListIndex - 1)
Me.listObjects.Requery
End Sub
thank you