473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to Add and Remove Items from ListBox via Subform

2
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
Aug 24 '10 #1
0 1099

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Stan Cook | last post by:
I was trying to take a list of files in a directory and remove all but the ".dbf" files. I used the following to try to remove the items, but they would not remove. Any help would be greatly...
3
by: darren | last post by:
How, using asp.net (vb.net), can I remove multiple selected items from a listbox. Everything I try does not seem to work. Thanks in advance.
0
by: Shawn K | last post by:
I populate a listbox with the following code when my form loads: lstBox.Items.Add("value"); Once the page loads, I give the user the ability to remove items from the list box by selecting an...
4
by: mostafa atalla | last post by:
How can I remove some selected items from the listBox in the run time ??
3
by: Hrcko | last post by:
How to remove a selected item from listBox? Hrcko
2
by: A.M | last post by:
Hi, How can remove all items is a list box or dropdown list box. I know that i can remove all items in Items collection by hand. I am looking for bultin member function doing that. Thanks,...
3
by: Bill Nguyen | last post by:
I use the following example (from another post) and it seemed to work fine. However, when I add the syntax to remove the selected item from the senderbox, I got error....
1
by: silverburgh.meryl | last post by:
How can I remove items from a stl vector if it exists on another vector? In Java, I can do this: vector v1 = new Vector(); // populate v1 vector v2 = new Vector(); // populate v2
10
by: pamelafluente | last post by:
Hi I have a sorted list with several thousands items. In my case, but this is not important, objects are stored only in Keys, Values are all Nothing. Several of the stored objects (might be a...
11
by: calred | last post by:
i am trying to remove items in a list if the items do not exist in another list but my program does not work the way i have expected for example: l = l2 = # l2 could be a list of raw...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.