W
Wazza
Hello All
I am new to posting on forums though i have browsed them often.
The question i have is to do with how to produce a Report using data that is
only remotely related to the Report's content. Let me explain.
The Report that i have created has a simple layout and is called
[StaffNotYetDoneCourse]. The Report's RowSource is the Staff Table. It has
a Title that is derived from a Table Column ([Courses].[Title]) and a
tabuated list of staff member's details Staff.StaffNo, Staff.LastName, Staff.
FirstName, and two rectangle objects ([Priority] and [Preferred Start Date]).
The resultant Report is used as a proformer for data collection.
There are three tables involved in the creation of the Report. Staff,
Training, and Courses. The Training Table has a Autonumber Primary Key and
is related to the Staff Table on the StaffNo (Text) Column. The Courses
Table has a list of Course.Titles that are used as Look-Up values for the
Training Table. The abreviated structure is as follows.
TABLE [Staff]
StaffNo (Text) Primary Key
LastName (Text)
FirstName (Text)
....
....
FinishDate (Date/Time)
TABLE [Training]
ID (Autonumber) Primary Key
StaffNo (Text) --- [Staff].[StaffNo]
CourseID (Number) --- [Courses].[ID]
StartDate (Date/Time)
FinishDate(Date/Time)
....
....
Comments (Memo)
TABLE [Courses]
ID (Autonumber) Primary Key
Title (Text)
....
....
Description (Memo)
Before Previewing the StaffNotYetDoneCourse Report the User has to select the
Report from a ListBox Me.rptName and select a [Courses].[ID] value from a
ComboBox that has a [Courses].[Title] text display.
I then open the Report with the following DoCmd. (This is modified cut &
paste I hope it makes logical sense)
Dim WC As String
Dim rs As Recordset
WC = "(Staff.StaffNo Not In (SELECT DISTINCT Staff.StaffNo " & _
"FROM Staff INNER JOIN Training ON Staff.StaffNo =
Training.StaffNo " & _
"WHERE (" & _
"((Training.CourseID=" & Me![txtCourse] & ") AND
(Not (Training.FinishDate) Is Null)) " & _
")" & _
"" & _
") " & _
"AND (Staff.FinishDate Is Null) "
Set rs = CurrentDb.OpenRecordset("Courses", dbOpenSnapshot)
rs.FindFirst "[ID] = " & Me![txtCourse]
If Not rs.NoMatch Then
DoCmd.OpenReport Me![Name], acViewDesign, , , acHidden
Reports(Me![Name])!TitleLabel2.Caption = "Course Name: " & rs![Title]
DoCmd.Close acReport, Me![Name], acSaveYes
End If
DoCmd.OpenReport Me![Name], acViewPreview, , WC
This works fine. But now my boss wants to print a StaffNotYetDoneCourse for
every [Course].[Title] and I do not know how to do this.
I need to be able to create a Query that results in every one who has not
done every course. I could put exactly what i have done already into a loop
(While Not Courses.EOF) but that does not allow me to do an initial preview
because i have to open the Report in Design View to Insert the Courses.Title
value for each course. I am finding this difficult because there is no
direct relation between Staff and Courses and the resultant recordset is
implied data because there is no record of who has not done a course only a
record of those who have done the course or at least who are booked to do the
course with a Null value in the FinishDate column.
I hope this makes sense to someone as i am finding it hard to understand and
i am the one doing it.
Thanks in advance for any help you can give me for this.
Wazza
I am new to posting on forums though i have browsed them often.
The question i have is to do with how to produce a Report using data that is
only remotely related to the Report's content. Let me explain.
The Report that i have created has a simple layout and is called
[StaffNotYetDoneCourse]. The Report's RowSource is the Staff Table. It has
a Title that is derived from a Table Column ([Courses].[Title]) and a
tabuated list of staff member's details Staff.StaffNo, Staff.LastName, Staff.
FirstName, and two rectangle objects ([Priority] and [Preferred Start Date]).
The resultant Report is used as a proformer for data collection.
There are three tables involved in the creation of the Report. Staff,
Training, and Courses. The Training Table has a Autonumber Primary Key and
is related to the Staff Table on the StaffNo (Text) Column. The Courses
Table has a list of Course.Titles that are used as Look-Up values for the
Training Table. The abreviated structure is as follows.
TABLE [Staff]
StaffNo (Text) Primary Key
LastName (Text)
FirstName (Text)
....
....
FinishDate (Date/Time)
TABLE [Training]
ID (Autonumber) Primary Key
StaffNo (Text) --- [Staff].[StaffNo]
CourseID (Number) --- [Courses].[ID]
StartDate (Date/Time)
FinishDate(Date/Time)
....
....
Comments (Memo)
TABLE [Courses]
ID (Autonumber) Primary Key
Title (Text)
....
....
Description (Memo)
Before Previewing the StaffNotYetDoneCourse Report the User has to select the
Report from a ListBox Me.rptName and select a [Courses].[ID] value from a
ComboBox that has a [Courses].[Title] text display.
I then open the Report with the following DoCmd. (This is modified cut &
paste I hope it makes logical sense)
Dim WC As String
Dim rs As Recordset
WC = "(Staff.StaffNo Not In (SELECT DISTINCT Staff.StaffNo " & _
"FROM Staff INNER JOIN Training ON Staff.StaffNo =
Training.StaffNo " & _
"WHERE (" & _
"((Training.CourseID=" & Me![txtCourse] & ") AND
(Not (Training.FinishDate) Is Null)) " & _
")" & _
"" & _
") " & _
"AND (Staff.FinishDate Is Null) "
Set rs = CurrentDb.OpenRecordset("Courses", dbOpenSnapshot)
rs.FindFirst "[ID] = " & Me![txtCourse]
If Not rs.NoMatch Then
DoCmd.OpenReport Me![Name], acViewDesign, , , acHidden
Reports(Me![Name])!TitleLabel2.Caption = "Course Name: " & rs![Title]
DoCmd.Close acReport, Me![Name], acSaveYes
End If
DoCmd.OpenReport Me![Name], acViewPreview, , WC
This works fine. But now my boss wants to print a StaffNotYetDoneCourse for
every [Course].[Title] and I do not know how to do this.
I need to be able to create a Query that results in every one who has not
done every course. I could put exactly what i have done already into a loop
(While Not Courses.EOF) but that does not allow me to do an initial preview
because i have to open the Report in Design View to Insert the Courses.Title
value for each course. I am finding this difficult because there is no
direct relation between Staff and Courses and the resultant recordset is
implied data because there is no record of who has not done a course only a
record of those who have done the course or at least who are booked to do the
course with a Null value in the FinishDate column.
I hope this makes sense to someone as i am finding it hard to understand and
i am the one doing it.
Thanks in advance for any help you can give me for this.
Wazza