Hi
I got two tables, people and events. Each have a .name and a .ID.
In a third table, participation, I have a many to many connection
between the two, conection people to events.
In a form, I got two listboxes populated with the .name and the .ID
from the two tables.
I want to select multiple (or single) elements in both listboxes, and
then push a button to create new records in a the participations table
for each combination of events and people, thus adding the
participation of all the selected people to all the selected events.
Any thoughts much appreciated.
K 2 1485
create an unbound form with two listboxes, one for people, one for
events. both have 2 columns, the unique ID field for each
person/event, and the name of the person/event. column widths:0;1
column count: 2. Set both of the listboxes' multiselect property to
Extended. In the button to add records, add this code (or fix it up
nicer, even!)
Private Sub cmdAddParticipants_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim varPerson As Variant, varEvent As Variant
Dim ctlPerson As Control, ctlEvent As Control
Set ctlPerson = Me.mslbxPeople
Set ctlEvent = Me.mslbxEvents
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEventParticipants", dbOpenTable,
dbAppendOnly)
For Each varPerson In ctlPerson.ItemsSelected
For Each varEvent In ctlEvent.ItemsSelected
rs.AddNew
rs.Fields("EmployeeID") = ctlPerson.ItemData(varPerson)
rs.Fields("EventID") = ctlEvent.ItemData(varEvent)
rs.Update
Next varEvent
Next varPerson
rs.Close
Set rs = Nothing
Set db = Nothing
MsgBox "done"
End Sub
I'm assuming you have these tables:
tblEventParticipants (ParticipantID, EventID)
tblEmployees (EmployeeID, FirstName, LastName,...)
tblEvents (EventID, EventName,...)
create an unbound form with two listboxes, one for people, one for
events. both have 2 columns, the unique ID field for each
person/event, and the name of the person/event. column widths:0;1
column count: 2. Set both of the listboxes' multiselect property to
Extended. In the button to add records, add this code (or fix it up
nicer, even!)
Private Sub cmdAddParticipants_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim varPerson As Variant, varEvent As Variant
Dim ctlPerson As Control, ctlEvent As Control
Set ctlPerson = Me.mslbxPeople
Set ctlEvent = Me.mslbxEvents
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEventParticipants", dbOpenTable,
dbAppendOnly)
For Each varPerson In ctlPerson.ItemsSelected
For Each varEvent In ctlEvent.ItemsSelected
rs.AddNew
rs.Fields("EmployeeID") = ctlPerson.ItemData(varPerson)
rs.Fields("EventID") = ctlEvent.ItemData(varEvent)
rs.Update
Next varEvent
Next varPerson
rs.Close
Set rs = Nothing
Set db = Nothing
MsgBox "done"
End Sub
I'm assuming you have these tables:
tblEventParticipants (ParticipantID, EventID)
tblEmployees (EmployeeID, FirstName, LastName,...)
tblEvents (EventID, EventName,...) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lamine Darbouche |
last post by:
Can anybody help?
I need to have three list boxes automatically populating each other, (ie
when region is selected from the first listbox, it will populate
automatically the second one which is...
|
by: buzz |
last post by:
I would appreciate a pointer.....
I have an asp page that links to an Access database and retrieves 2500
records and each record line has two listboxes. The problem is, although
everything is...
|
by: Jimmy Tran |
last post by:
Hi everyone,
I have a form consisting of a combo box and two listboxes, they get
their control source from a query. the whole form suppose to update a
table. when i run the form, i pick an item...
|
by: bill yeager |
last post by:
I have several template columns inside of a datagrid.
Inside of these template columns are databound listboxes:
<asp:TemplateColumn HeaderText="Crew Chiefs">
<ItemTemplate>
<asp:listbox...
|
by: collie |
last post by:
Hi,
I have 2 listboxes. The first gets populated from the db as soon as
the page loads. The second listbox get populated based on the user's
selection from the first listbox. However,...
|
by: KBuser |
last post by:
I'm building an internal site which will allow for extremely
customizable queries to be run against our SQL Server (2000) DB. The
page is done in ASP .net 2.0, with C# code behind.
The initial...
|
by: rdemyan via AccessMonster.com |
last post by:
I have to import building information from another system. I've decided to
keep track of each set of data downloaded by including a Download_Date. That
way I keep historical data.
My table has...
|
by: koonda |
last post by:
Hi all,
I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
|
by: Anil Gupte |
last post by:
I am having some issues with Listboxes
Here is my code:
Dim DSContent As New DataSet
DSContent = L3GContent.GlobalDataSet
URLListBox.BeginUpdate()
For Each dr As DataRow In...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |