473,405 Members | 2,379 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,405 software developers and data experts.

A2K3: design for pupil incidents database, help needed

I need to knock something up quickly to allow a teacher to record incidents
at a school. This means logging the type of incident e.g bullying, fight
etc and the pupils that were involved.

So I have tblPupils, tblPupilEventLink (the junction table) and
tblIncidents. tblPupils relates to the junction table on PupilID and
tblIncidents relates
using IncidentID, as this is clearly a many to many relationship - many
events can involve a pupil and an event could relate to many pupils.

Now I see how I can create a form based on tblEvents and have a subform
based on tblPupils. The form and subform link on EventID and I can choose
pupils for a new event.

However instead of a continuous subform I would like to have a multi-select
listbox instead (maybe embedded into the subform?). This would be much
easier to use. The teacher can quickly select all the pupils involved and
click ok.

Naturally this is where I'm coming a cropper. Any advice on how to do this?
I would also like to have a combo box which would allow the user to filter
the listbox by class.

thanks
Martin

Jan 8 '06 #1
9 1511
If you're using a multi select listbox then you have to insert the names
selected from the list into the tables using code, you can't bind the
listbox.

This means that as incidents are reviewed you also need code to select the
pupils in the list and if amendments are made code to update the tables
(mainly drop and create records).
--
Terry Kreft

"Deano" <de***@mailinator.com> wrote in message
news:43**********************@ptn-nntp-reader02.plus.net...
I need to knock something up quickly to allow a teacher to record incidents
at a school. This means logging the type of incident e.g bullying, fight
etc and the pupils that were involved.

So I have tblPupils, tblPupilEventLink (the junction table) and
tblIncidents. tblPupils relates to the junction table on PupilID and
tblIncidents relates
using IncidentID, as this is clearly a many to many relationship - many
events can involve a pupil and an event could relate to many pupils.

Now I see how I can create a form based on tblEvents and have a subform
based on tblPupils. The form and subform link on EventID and I can choose
pupils for a new event.

However instead of a continuous subform I would like to have a
multi-select
listbox instead (maybe embedded into the subform?). This would be much
easier to use. The teacher can quickly select all the pupils involved and
click ok.

Naturally this is where I'm coming a cropper. Any advice on how to do
this?
I would also like to have a combo box which would allow the user to filter
the listbox by class.

thanks
Martin

Jan 8 '06 #2
"Deano" <de***@mailinator.com> wrote in
news:43**********************@ptn-nntp-reader02.plus.net:
I need to knock something up quickly to allow a teacher to
record incidents at a school. This means logging the type of
incident e.g bullying, fight etc and the pupils that were
involved.

So I have tblPupils, tblPupilEventLink (the junction table)
and tblIncidents. tblPupils relates to the junction table on
PupilID and tblIncidents relates
using IncidentID, as this is clearly a many to many
relationship - many events can involve a pupil and an event
could relate to many pupils.

Now I see how I can create a form based on tblEvents and have
a subform based on tblPupils. The form and subform link on
EventID and I can choose pupils for a new event.

However instead of a continuous subform I would like to have a
multi-select listbox instead (maybe embedded into the
subform?). This would be much easier to use. The teacher can
quickly select all the pupils involved and click ok.

Naturally this is where I'm coming a cropper. Any advice on
how to do this? I would also like to have a combo box which
would allow the user to filter the listbox by class.

I posted some code to do something very similar a little mmore
than a year ago. (Bonjour José).

Just a simple listbox on the mainform will do. Double-Clicking
on a student name will immediately move it to the subform, so
you dont need the multiselect feature.

Notes:
Translate persons, to tblPupils,
clubmenbers to tblPupilEventLink and
clubs to tblEvents

The rowsource for the listbox is:
SELECT persons.personID, persons.person
FROM persons
WHERE (((persons.personID) Not In (select personID from
clubmembers where clubID = forms!form1.clubid)));
Private Sub List3_AfterUpdate()
DoCmd.RunSQL "insert into clubmembers " _
& "(clubID,personID) " _
& values ('" & Me.clubID.Value _
& "','" & Me.Combo3.Value & "');"
Me.Child1.Form.Requery 'show the new record
Me.List3.Requery ' hide the missing record
End Sub

Private Sub List_Enter()
Me.List3.Requery
End Sub

Private Sub Child1_Exit(Cancel As Integer)
' reinsert rows in listbox if we deleted them from the subform
Me.List3.Requery
End Sub

The class filter should just go in the rowsource for the
listbox.

--
Bob Quintal

PA is y I've altered my email address.
Jan 8 '06 #3
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn*********************@207.35.177.135:
"Deano" <de***@mailinator.com> wrote in
news:43**********************@ptn-nntp-reader02.plus.net:
I need to knock something up quickly to allow a teacher to
record incidents at a school. This means logging the type of
incident e.g bullying, fight etc and the pupils that were
involved.

So I have tblPupils, tblPupilEventLink (the junction table)
and tblIncidents. tblPupils relates to the junction table on
PupilID and tblIncidents relates
using IncidentID, as this is clearly a many to many
relationship - many events can involve a pupil and an event
could relate to many pupils.

Now I see how I can create a form based on tblEvents and have
a subform based on tblPupils. The form and subform link on
EventID and I can choose pupils for a new event.

However instead of a continuous subform I would like to have
a multi-select listbox instead (maybe embedded into the
subform?). This would be much easier to use. The teacher
can quickly select all the pupils involved and click ok.

Naturally this is where I'm coming a cropper. Any advice on
how to do this? I would also like to have a combo box which
would allow the user to filter the listbox by class.
I posted some code to do something very similar a little mmore
than a year ago. (Bonjour José).

Just a simple listbox on the mainform will do. Double-Clicking
on a student name will immediately move it to the subform, so
you dont need the multiselect feature.

Notes:
Translate persons, to tblPupils,
clubmenbers to tblPupilEventLink and
clubs to tblEvents

The rowsource for the listbox is:
SELECT persons.personID, persons.person
FROM persons
WHERE (((persons.personID) Not In (select personID from
clubmembers where clubID = forms!form1.clubid)));
Private Sub List3_AfterUpdate()
DoCmd.RunSQL "insert into clubmembers " _
& "(clubID,personID) " _
& values ('" & Me.clubID.Value _
& "','" & Me.Combo3.Value & "');"
Me.Child1.Form.Requery 'show the new record
Me.List3.Requery ' hide the missing record
End Sub


OOPS. & "','" & Me.Combo3.Value & "');" should be
& "','" & Me.List3.Value & "');"

Private Sub List3_Enter()
Me.List3.Requery
End Sub

Private Sub Child1_Exit(Cancel As Integer)
' reinsert rows in listbox if we deleted them from the subform
Me.List3.Requery
End Sub

The class filter should just go in the rowsource for the
listbox.


--
Bob Quintal

PA is y I've altered my email address.
Jan 8 '06 #4
Bob Quintal wrote:

Thanks Bob, I have been trying this out but I have a few queries below
before I can get it working. I have amended the code as suggested.
Just a simple listbox on the mainform will do. Double-Clicking
on a student name will immediately move it to the subform, so
you dont need the multiselect feature. The rowsource for the listbox is:

SELECT tblPupils.PupilID, tblPupils.Surname
FROM tblPupils
WHERE (((tblPupils.PupilID) Not In (select PupilID from
tblPupilEventLink where EventID = Forms!Form1.EventID)));

Does Form1 refer to the main form where the listbox is placed?
When the form opens to run this query I get prompted for a parameter value
for the Forms!Form1.clubid part. I have this control on the main form. I
guess at this point there is no link between the event and the list of
pupils in the listbox. Should I simply ignore the message when starting the
form?
BTW I'm using just tblEvents as the datasource for Form1.
Private Sub List3_AfterUpdate()
DoCmd.RunSQL "insert into tblPupilEventLink " _
& "(EventID,PupilID) " _
& values ('" & Me.EventID.Value _
& "','" & "','" & Me.List3.Value & "');"
Me.Child1.Form.Requery 'show the new record
Me.List3.Requery ' hide the missing record
End Sub

I'm getting a syntax error here. What is "values"?

Jan 9 '06 #5
"Deano" <de***@mailinator.com> wrote in
news:43***********************@ptn-nntp-reader03.plus.net:
Bob Quintal wrote:

Thanks Bob, I have been trying this out but I have a few
queries below before I can get it working. I have amended the
code as suggested.
Just a simple listbox on the mainform will do.
Double-Clicking on a student name will immediately move it to
the subform, so you dont need the multiselect feature.
The rowsource for the listbox is:

SELECT tblPupils.PupilID, tblPupils.Surname
FROM tblPupils
WHERE (((tblPupils.PupilID) Not In (select PupilID from
tblPupilEventLink where EventID = Forms!Form1.EventID)));

Does Form1 refer to the main form where the listbox is placed?


yes it does, if your form has a different name, adjust
accordingly.
When the form opens to run this query I get prompted for a
parameter value for the Forms!Form1.clubid part. I have this
control on the main form. I guess at this point there is no
link between the event and the list of pupils in the listbox.
Should I simply ignore the message when starting the form?
BTW I'm using just tblEvents as the datasource for Form1.
You should not get this prompt. Forms!Form1.clubid should refer
to eventId, probably.


Private Sub List3_AfterUpdate()
DoCmd.RunSQL "insert into tblPupilEventLink " _
& "(EventID,PupilID) " _
& values ('" & Me.EventID.Value _
& "','" & "','" & Me.List3.Value & "');"
Me.Child1.Form.Requery 'show the new record
Me.List3.Requery ' hide the missing record
End Sub

I'm getting a syntax error here. What is "values"?


In a SQL Insert statement (which adds records), the list of
values is what goes into the new record, in the same order as
the list of fields above it. You have two commas there, and
single quotes around the values. If your IDs are numeric, you
will want the list to be (1,47), so the code would be
& " values (" & me.eventID & "," & me.list3.value & ");"
If they are string, your list should be ('event1','student2')
and you need the single quote marks.
& " values ('" & me.eventID & "','" & me.list3.value & "');"

You are also missing a doublequote before the word values.
--
Bob Quintal

PA is y I've altered my email address.
Jan 10 '06 #6
Bob Quintal wrote:

Hooray i made it work. The parameter error was my fault (used the wrong
form name). The afterupdate for the list box has one too many commas. Took
that out and it worked fine.

Now I'm going to work out how to move records back from the subform into the
listbox and also apply the class filter.

Thanks Bob, this looks quite nice and I would not have thought to use this
sort of interface.
Jan 10 '06 #7
Bob Quintal wrote:
"Deano" <de***@mailinator.com> wrote in
news:43**********************@ptn-nntp-reader02.plus.net:
I need to knock something up quickly to allow a teacher to
record incidents at a school. This means logging the type of
incident e.g bullying, fight etc and the pupils that were
involved.

Just a simple listbox on the mainform will do. Double-Clicking
on a student name will immediately move it to the subform, so
you dont need the multiselect feature.

I think I need some SQL help! Read on...
The rowsource for the listbox is:


SELECT tblPupils.PupilID, tblPupils.Surname
FROM tblPupils
WHERE (((tblPupils.PupilID) Not In (select PupilID from
tblPupilIncidentLink where IncidentID = Forms!Form1.IncidentID)));

If I create a new incident then the selected pupil now has an entry in my
junction table, tblPupilIncidentLink, along with the IncidentID.
The above SQL means that when I try to select a pupil from the listbox, the
INSERT statement in the afterupdate event won't add this pupil to the
junction table because they are already there. I think the crucial code is
the "Not In" bit.

Is there a way of tweaking the SQL to allow a pupil to be linked to more
than one event in the junction table?

e.g at the moment I have this sort of situation (2 events with no repeated
pupils which isn't realistic)

PupilID------IncidentID
10 3
11 4
21 3
22 3
whereas I would like to see this, so I can show that, for example, pupils 10
and 11 have been involved in more than one incident;

PupilID------IncidentID
10 3
10 4
11 4
11 3
21 3
22 3
Or should I be working on a temporary empty junction table for each new
incident and then append the inserted records to tblPupilEventLink_Final?

Thanks for any further thoughts on this.


Jan 10 '06 #8
Deano wrote:
Bob Quintal wrote:
"Deano" <de***@mailinator.com> wrote in
news:43**********************@ptn-nntp-reader02.plus.net:
I need to knock something up quickly to allow a teacher to
record incidents at a school. This means logging the type of
incident e.g bullying, fight etc and the pupils that were
involved.


Just a simple listbox on the mainform will do. Double-Clicking
on a student name will immediately move it to the subform, so
you dont need the multiselect feature.


I think I need some SQL help! Read on...


<snipped>

Ignore me, talking complete rubbish again! I only had a one-to-one
relationship between tblPupils and the junction table, now fixed and seems
to be working.
Jan 10 '06 #9
"Deano" <de***@mailinator.com> wrote in
news:43***********************@ptn-nntp-reader03.plus.net:
Bob Quintal wrote:

Hooray i made it work. The parameter error was my fault (used
the wrong form name). The afterupdate for the list box has
one too many commas. Took that out and it worked fine.

Now I'm going to work out how to move records back from the
subform into the listbox and also apply the class filter.
That's so easy: just delete the record from the subform, then
requery the listbox.

The class filter is not that difficult either, if your
structures are good. A combobox rowsource of "SELECT DISTINCT
Classroom from
Students;" should do there, and tour listbox control source just
needs to add to the where clause " AND students.class = " &
Forms!form1.combobox", adding single quotes around the combobox
reference if it contains text.
Thanks Bob, this looks quite nice and I would not have thought
to use this sort of interface.


Glad to share the knowledge.

--
Bob Quintal

PA is y I've altered my email address.
Jan 10 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Don Vaillancourt | last post by:
Hello all, Over the years as I design more database schemas the more I come up with patterns in database design. The more patterns I recognize the more I want to try to design some kind of...
1
by: Corinne | last post by:
I have a database that contains the details of pupils in a school. What I would like to do may not be possible but I thought I would ask anyway. Each year the pupils move to a different class,...
1
by: John M | last post by:
Hi, I've produced a simple database for my school to keep a log of pupil behavour incidents. This all seems very negative, so we would now like to add to it a log of positive pupil activities. ...
19
by: David W. Fenton | last post by:
I'm setting up a project for a client on a new Windows Terminal Server. The application is currently in A2K, but the sysadmin does not want to install that, he wants to install A2K3, because Office...
2
by: Darryl | last post by:
I'm working on converting an A97 DB that someone else wrote to A2K3. It's converted fine, as far as I can see. Now while making changes, I've removed several buttons on a form that called...
4
by: dwight | last post by:
hi, i am making an asp.net front end to a sql server database. The system will become quite large and will focus on different 'areas' or information When the user logs in they get to a main...
0
by: dwight | last post by:
hi, i am making an asp.net front end to a sql server database. The system will become quite large and will focus on different 'areas' or information When the user logs in they get to a main...
13
by: Arno R | last post by:
Hi all, I am deploying an A2k app to users with different versions of Access. Using Access 2000 the relinking on startup (on deploying a new frontend or when backend has changed) is very fast....
8
by: =?Utf-8?B?QmVu?= | last post by:
Hi, I have a couple of questions about the proper design of classes. I'll use a simple Customer class for my question. 1) Lets say that I have this Customer class like I said, and I want to...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.