duplicate lines in multiple form and query (1 Viewer)

Giles_E

New member
Local time
Today, 15:53
Joined
Jul 8, 2015
Messages
3
This is my first major database project, so apologies if i don't explain it very well.

The purpose of my database is to keep a record of training activities undertaken by staff. There is therefore a multiple form which displays, for a specified worker, the list of all the required activities. Each line has a button which opens another form to allow an activity to be started (together with start date and other info). The main tables are Worker, Activities, and a junction table Worker2Activities. On closing the second form and refreshing the first one, the started activity is correctly recorded, but on as many lines as there are staff on the course. To make matters worse, these also appear when i then select another worker (and if i create another worker, the number of lines goes up by one for all of them). The Worker2Activities table correctly show one new record created. Any hints as to where to start would be appreciated... PS I'm about to go on leave in about 24 hours, so if you reply and i don't comment it doesn't mean i'm not interested!
 

Attachments

  • SimTrack.zip
    225.7 KB · Views: 53

Giles_E

New member
Local time
Today, 15:53
Joined
Jul 8, 2015
Messages
3
PS, to see this in action, select switchboard, then select worker (Form_select worker), then select 'go to record of learning' (form Record_of-Learning)
also the version i originally attached as a zip file doesn't work; sorry. i'm attaching one which does...
 

Attachments

  • ClearTrack.zip
    238.9 KB · Views: 61

spikepl

Eledittingent Beliped
Local time
Today, 16:53
Joined
Nov 3, 2010
Messages
6,142
Honestly,doyourselfafavourandrewriteyournarrative,usingspaces,lineshiftsetctosplitthethingintoparagraphseachconcerningonecontiguousthought,insteadofthebigblackblobyou'vepresentedsofar.Wereadmanyposts,andIamoneofthosewhocannotbebothered,ifthepostermadenoefforttomakehispostreadable.
 

Giles_E

New member
Local time
Today, 15:53
Joined
Jul 8, 2015
Messages
3
Apologies… I’ll try again

Purpose
To keep a record of learning of trainees, as well as to indicate learning activities required. Although at present only one course is included, the database needs to allow for other courses to be added if required.

Tables
· Workers
· Activities
o Learning Journal
o Stage
o Activity Type
· Workers2Activities Junction Table, includes dates started and completed, and status_ID
o Status (blank, possible, started , completed)
· Courses
o Suppliers
· Courses2Workers Junction table (includes dates and selection_ID)
o Selection

NB as well as being in a 1 to many relationship to Courses2Workers, Courses is also in a one-many relationship with Activities, as activities undertaken depend on course selected.

Queries (the ones that I think are relevant to this issue) and the tables they’re built from:
· Query_CoursesbyWorker (Workers, Courses2Workers, Selections, Courses)
· Query_RequiredActivitesbyWorker (All the tables in Query_CoursesbyWorker plus Activities, learning journals, stages, activity types, and suppliers)
· Query_CompletedActivitiesbyWorker (Status, Worker2Activities, Query_RequiredActivitiesbyWorker)( join include all records from Worker2Activities and those from Query_RequiredActivitiesbyWorker where the fields are equal (Activity_ID)
· Query_BothActivitiesbyWorker (Query_CompletedActivitybyWorker, Activities, Query_RequiredActivitiesbyWorker)(joins: all records in RequiredActivitiesbyWorker and only those in Activities where the fields are equal (Activity_ID), all records from Activites and only those from Query_CompletedActivitiesbyWorker where the fields are equal (Activity_ID)

Relevant Forms
· Form_Select Worker (accessed from Switchboard): relevant button is ‘go to record of learning’
Code to open Record of Learning

Private Sub Command14_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Record_of_Learning"
stLinkCriteria = "[Worker_ID] = " & Me.Worker_ID & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

· Record of Learning – based on Query_BothActivitiesbyWorker, displayed as multiple/continuous form. Includes a start button that opens ‘Start Activity’ (see below): code to do this

Code to open Start Activity
Private Sub Command171_Click()
DoCmd.OpenForm "Start Activity", OpenArgs:=Me.Worker_ID & "|" & Me.Activity_ID
End Sub

· Start Activity – allows new activity to be selected, and relevant dates. Save and close button included (it creates a new record in Workers2Activities)
· (there should be an edit activity button and form but I haven’t added these yet)

The problem
Once I have added info on Start Activity form, and close it, when I refresh Record of Learning it shows the relevant activity as updated correctly, but on multiple lines. The number of duplications equal the number of workers who are on the course. Also (and worse) these duplications, with the same dates etc, appear in the other workers records of learning as well. The same duplication appears in the Query_BothActivitiesbyWorker; However the Worker2Activities table is correctly increased by one record.
(there may be a neater way of starting/updating records other than by opening a different form but I don’t know how)

Hope this is clearer…
 

Users who are viewing this thread

Top Bottom