Code:
Private Sub Command34_Click()Dim stDocName As String
Dim dbs As Database
Dim rst As Recordset
Dim mgrdbs As Database
Dim mgrrst As Recordset
Dim strSQL As String
Dim clocknum As String
Dim fullname As String
Dim manager As String
Dim TrainingDescription As String
Dim mgrdbstrn As Database
Dim mgrrsttrn As Recordset
Dim TrainingDescription2 As String
Dim qdf As QueryDef
stDocName = "Employee_Training"
On Error GoTo Main_GENTEMP_Err
' Qry_temptrain Clear
DoCmd.OpenQuery "Qry_temptrain01", acNormal, acEdit
DoCmd.OpenQuery "Qry_temptrain02", acNormal, acEdit
DoCmd.OpenQuery "Qry_temptrain03", acNormal, acEdit
DoCmd.OpenQuery "Qry_temptrain04", acNormal, acEdit
DoCmd.OpenQuery "Qry_temptrain05", acNormal, acEdit
DoCmd.OpenQuery "Qry_temptrain06", acNormal, acEdit
' setup the index.html file
'
'
Close #1
Open "\\bciappsrv1\trainingrecords\index.html" For Output As #1
Print #1, "<html>"
Print #1, ""
Print #1, "<head>"
Print #1, "<title>Training Records</title>"
Print #1, "</head>"
Print #1, ""
Print #1, "<body bgcolor=" & Chr(34) & "#FFFFFF" & Chr(34) & ">"
Print #1, "<script language=" & Chr(34) & "JavaScript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">"
Print #1, "<!--"
Print #1, "// original code by Bill Trefzger 12/12/96"
Print #1, "function go1(){"
Print #1, "if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != " & Chr(34) & "none" & Chr(34) & ") {"
Print #1, "location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value"
Print #1, " }"
Print #1, " }"
Print #1, "//-->"
Print #1, "<!--"
Print #1, "function go2(){"
Print #1, "if (document.selecter2.select1.options[document.selecter2.select1.selectedIndex].value != " & Chr(34) & "none" & Chr(34) & ") {"
Print #1, "location = document.selecter2.select1.options[document.selecter2.select1.selectedIndex].value"
Print #1, " }"
Print #1, " }"
Print #1, "//-->"
Print #1, "<!--"
Print #1, "function go3(){"
Print #1, "if (document.selecter3.select1.options[document.selecter3.select1.selectedIndex].value != " & Chr(34) & "none" & Chr(34) & ") {"
Print #1, "location = document.selecter3.select1.options[document.selecter3.select1.selectedIndex].value"
Print #1, " }"
Print #1, " }"
Print #1, "//-->"
Print #1, "function go4(){"
Print #1, "if (document.selecter4.select1.options[document.selecter4.select1.selectedIndex].value != " & Chr(34) & "none" & Chr(34) & ") {"
Print #1, "location = document.selecter4.select1.options[document.selecter4.select1.selectedIndex].value"
Print #1, " }"
Print #1, " }"
Print #1, "//-->"
Print #1, "</script>"
Print #1, "<BR>"
Print #1, "<table border=" & Chr(34) & "0" & Chr(34) & ">"
Print #1, " <tr>"
Print #1, " <td>Select Employee</td>"
Print #1, " </tr>"
Print #1, " <tr><td>"
Print #1, "<script language=" & Chr(34) & "JavaScript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">"
Print #1, "<!-- "
Print #1, "document.write('<form name=" & Chr(34) & "selecter1" & Chr(34) & "><select name=" & Chr(34) & "select1" & Chr(34) & "onchange=" & Chr(34) & "go1()" & Chr(34) & ">');"
Print #1, "document.write('<option value=none>Training by Employee');"
Print #1, "document.write('<option value=none>--------------------');"
' Return reference to current database.
Set dbs = CurrentDb
strSQL = " SELECT Employee.[Clock Number], Employee.FName, Employee.Lname, Employee.Archive"
strSQL = strSQL & " FROM Employee"
strSQL = strSQL & " WHERE (((Employee.Archive)=No))"
strSQL = strSQL & " ORDER BY Employee.Lname;"
Set rst = dbs.OpenRecordset(strSQL)
' Start of Loop
With rst
Do While Not .EOF
clocknum = ![Clock Number]
fullname = !Lname & ", " & !FName
' fullname = StrReplace(fullname, "'", """)
fullname = UCase(StrReplace(fullname, "'", " "))
Print #1, "document.write('<option value=" & Chr(34) & "http://oldintranet.net/BCIntranet/hr/trainingrecords/employees/" & clocknum & ".cfm" & Chr(34) & ">" & fullname & "');"
'Call waitasec(1)
'DoCmd.OpenReport stDocName, acPreview, , "[Clock Number] = " & clocknum
'Call waitasec(1)
'Reports![Employee_Training].Filter = "[Clock Number] = " & clocknum
'================================================
'
' create query to output report in html format
'
'
'
On Error Resume Next
DoCmd.DeleteObject acQuery, "Qry_Employee_Training"
On Error GoTo Main_GENTEMP_Err
strSQL = "SELECT Temptrain.LName, Temptrain.Overdue, Temptrain.Name, Temptrain.Title, Temptrain.JobTitleid, Departments.Department, Temptrain.[Training Description], Temptrain.[Clock Number], Managers.Manager, Temptrain.Date, Temptrain.IDisotraining, Temptrain.id"
strSQL = strSQL & " FROM (Temptrain INNER JOIN Departments ON Temptrain.Departmentid = Departments.Departmentid) INNER JOIN Managers ON Temptrain.Managerid = Managers.Managerid"
strSQL = strSQL & " WHERE (((Temptrain.[Clock Number])=" & clocknum & "));"
' Create new query.
Set qdf = dbs.CreateQueryDef("Qry_Employee_Training", strSQL)
DoCmd.OutputTo acOutputReport, stDocName, acFormatHTML, "\\bciappsrv1\trainingrecords\employees\" & clocknum & ".cfm", False, "\\ted\training\employees\employeetemplate.cfm"
'Call waitasec(1)
'DoCmd.close acReport, stDocName
'DoCmd.OpenForm "Main"
'Form.Refresh
'Call waitasec(1)
.MoveNext
Loop
End With
rst.Close
Set dbs = Nothing
'End of loop
Print #1, "document.write('</select>');"
'Print #1, "document.write('<input type=" & Chr(34) & "button" & Chr(34) & " value=" & Chr(34) & "go1" & Chr(34) & " onclick=" & Chr(34) & "go1()" & Chr(34) & ">');"
Print #1, "document.write('</form>');"
Print #1, "// end hiding contents -->"
Print #1, "</script>"
Print #1, " </tr></td>"
'-------- end of writing employee files and the first employee drop down list -------
' start of 2nd employee number drop down list.
' start of 2nd employee number drop down list.
' start of 2nd employee number drop down list.
' start of 2nd employee number drop down list.
' start of 2nd employee number drop down list.
Print #1, " <tr>"
Print #1, " <td>Select clock number</td>"
Print #1, " </tr>"
Print #1, " <tr><td>"
Print #1, "<script language=" & Chr(34) & "JavaScript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">"
Print #1, "<!-- "
Print #1, "document.write('<form name=" & Chr(34) & "selecter3" & Chr(34) & "><select name=" & Chr(34) & "select1" & Chr(34) & "onchange=" & Chr(34) & "go3()" & Chr(34) & ">');"
Print #1, "document.write('<option value=none>Training by Clock Number');"
Print #1, "document.write('<option value=none>--------------------');"
' Return reference to current database.
Set dbs = CurrentDb
strSQL = " SELECT Employee.[Clock Number], Employee.FName, Employee.Lname, Employee.Archive"
strSQL = strSQL & " FROM Employee"
strSQL = strSQL & " WHERE (((Employee.Archive)=No))"
strSQL = strSQL & " ORDER BY Employee.[Clock Number];"
Set rst = dbs.OpenRecordset(strSQL)
With rst
Do While Not .EOF
clocknum = ![Clock Number]
fullname = !Lname & ", " & !FName
fullname = UCase(StrReplace(fullname, "'", " "))
Print #1, "document.write('<option value=" & Chr(34) & "http://oldintranet.net/BCIntranet/hr/trainingrecords/employees/" & clocknum & ".cfm" & Chr(34) & ">" & clocknum & " - " & fullname & "');"
On Error Resume Next
DoCmd.DeleteObject acQuery, "Qry_Employee_Training"
On Error GoTo Main_GENTEMP_Err
strSQL = "SELECT Temptrain.LName, Temptrain.Overdue, Temptrain.Name, Temptrain.Title, Temptrain.JobTitleid, Departments.Department, Temptrain.[Training Description], Temptrain.[Clock Number], Managers.Manager, Temptrain.Date, Temptrain.IDisotraining, Temptrain.id"
strSQL = strSQL & " FROM (Temptrain INNER JOIN Departments ON Temptrain.Departmentid = Departments.Departmentid) INNER JOIN Managers ON Temptrain.Managerid = Managers.Managerid"
strSQL = strSQL & " WHERE (((Temptrain.[Clock Number])=" & clocknum & "));"
' Create new query.
Set qdf = dbs.CreateQueryDef("Qry_Employee_Training", strSQL)
.MoveNext
Loop
End With
rst.Close
Set dbs = Nothing
'End of loop
Print #1, "document.write('</select>');"
Print #1, "document.write('</form>');"
Print #1, "// end hiding contents -->"
Print #1, "</script>"
Print #1, " </tr></td>"
' end of 2nd employee number drop down list.
'*************************************************************************************
Print #1, " <tr><td>Select Manager</td></tr>"
Print #1, " <tr><td>"
Print #1, "<script language=" & Chr(34) & "JavaScript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">"
Print #1, "<!-- "
Print #1, "document.write('<form name=" & Chr(34) & "selecter2" & Chr(34) & "><select name=" & Chr(34) & "select1" & Chr(34) & "onchange=" & Chr(34) & "go2()" & Chr(34) & ">');"
Print #1, "document.write('<option value=none>Employees by Manager');"
Print #1, "document.write('<option value=none>--------------------');"
' Return reference to current database.
Set mgrdbs = CurrentDb
strSQL = " SELECT Managers.Managerid, Managers.Manager FROM Managers ORDER BY Managers.Manager;"
Set mgrrst = mgrdbs.OpenRecordset(strSQL)
' Start mgr Loop
With mgrrst
Do While Not .EOF
manager = StrReplace(!manager & "", " ", "")
Print #1, "document.write('<option value=" & Chr(34) & "http://oldintranet.net/BCIntranet/hr/trainingrecords/employees/" & manager & ".cfm" & Chr(34) & ">" & !manager & "');"
'DoCmd.OpenReport stDocName, acPreview, , "[manager] = " & Chr(34) & !manager & Chr(34)
'Reports![Employee_Training].Filter = "[manager] = " & Chr(34) & !manager & Chr(34)
On Error Resume Next
DoCmd.DeleteObject acQuery, "Qry_Employee_Training"
On Error GoTo Main_GENTEMP_Err
strSQL = "SELECT Temptrain.LName, Temptrain.Overdue, Temptrain.Name, Temptrain.Title, Temptrain.JobTitleid, Departments.Department, Temptrain.[Training Description], Temptrain.[Clock Number], Managers.Manager, Temptrain.Date, Temptrain.IDisotraining, Temptrain.id"
strSQL = strSQL & " FROM (Temptrain INNER JOIN Departments ON Temptrain.Departmentid = Departments.Departmentid) INNER JOIN Managers ON Temptrain.Managerid = Managers.Managerid"
strSQL = strSQL & " WHERE (([manager]='" & !manager & "'));"
' Create new query.
Set qdf = mgrdbs.CreateQueryDef("Qry_Employee_Training", strSQL)
manager = UCase(StrReplace(manager, "'", " "))
DoCmd.OutputTo acOutputReport, stDocName, acFormatHTML, "\\bciappsrv1\trainingrecords\employees\" & manager & ".cfm", , "\\bciappsrv1\trainingrecords\employees\employeetemplate.cfm"
DoCmd.Close acReport, stDocName
.MoveNext
Loop
End With
mgrrst.Close
Set mgrdbs = Nothing
'End mgr loop
Print #1, "document.write('</select>');"
'Print #1, "document.write('<input type=" & Chr(34) & "button" & Chr(34) & " value=" & Chr(34) & "go2" & Chr(34) & " onclick=" & Chr(34) & "go2()" & Chr(34) & ">');"
Print #1, "document.write('</form>');"
Print #1, "// end hiding contents -->"
Print #1, "</script>"
Print #1, " </tr></td>"
'-------- end of writing Mgr select list
'*************************************************************************************
Print #1, " <tr><td>Select by Training</td></tr>"
Print #1, " <tr><td>"
Print #1, "<script language=" & Chr(34) & "JavaScript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">"
Print #1, "<!-- "
Print #1, "document.write('<form name=" & Chr(34) & "selecter4" & Chr(34) & "><select name=" & Chr(34) & "select1" & Chr(34) & "onchange=" & Chr(34) & "go4()" & Chr(34) & ">');"
Print #1, "document.write('<option value=none>Qualified for:');"
Print #1, "document.write('<option value=none>--------------------');"
' Return reference to current database.
Set mgrdbstrn = CurrentDb
' Qualified
' strSQL = "SELECT [ISO Required Training Descriptions].[Training Description], [ISO Required Training Descriptions].IDisotraining, Count([Training Subjects].IDisotraining) AS CountOfIDisotraining FROM [ISO Required Training Descriptions] INNER JOIN [Training Subjects] ON [ISO Required Training Descriptions].IDisotraining = [Training Subjects].IDisotraining GROUP BY [ISO Required Training Descriptions].[Training Description], [ISO Required Training Descriptions].IDisotraining HAVING (((Count([Training Subjects].IDisotraining))>0));"
strSQL = "SELECT [ISO Required Training Descriptions].[Training Description], [ISO Required Training Descriptions].IDisotraining, Count([Training Subjects].IDisotraining) AS CountOfIDisotraining, Count([Employee Training].IDtraining) AS CountOfIDtraining FROM [Employee Training] INNER JOIN ([ISO Required Training Descriptions] INNER JOIN [Training Subjects] ON [ISO Required Training Descriptions].IDisotraining = [Training Subjects].IDisotraining) ON [Employee Training].IDtrainsubject = [Training Subjects].IDtrainsubject WHERE ((([ISO Required Training Descriptions].[Training Description]) Like 'Qualified*')) GROUP BY [ISO Required Training Descriptions].[Training Description], [ISO Required Training Descriptions].IDisotraining HAVING (((Count([Training Subjects].IDisotraining))>=1) AND ((Count([Employee Training].IDtraining))>=1));"
Set mgrrsttrn = mgrdbstrn.OpenRecordset(strSQL)
' Start mgr Loop
With mgrrsttrn
Do While Not .EOF
TrainingDescription = StrReplace(![Training Description] & "", " ", "")
TrainingDescription = StrReplace(TrainingDescription & "", ":", "")
TrainingDescription = StrReplace(TrainingDescription & "", """", "")
TrainingDescription = StrReplace(TrainingDescription & "", "&", "")
TrainingDescription = StrReplace(TrainingDescription & "", "/", "-")
TrainingDescription = StrReplace(TrainingDescription & "", ")", "")
TrainingDescription = StrReplace(TrainingDescription & "", "(", "")
TrainingDescription = StrReplace(TrainingDescription & "", ",", "")
TrainingDescription = StrReplace(TrainingDescription & "", "'", " ")
TrainingDescription = StrReplace(TrainingDescription & "", "%", " ")
TrainingDescription2 = StrReplace(![Training Description] & "", " ", "-")
TrainingDescription2 = StrReplace(TrainingDescription2 & "", "&", "")
TrainingDescription2 = StrReplace(TrainingDescription2 & "", "'", "")
TrainingDescription2 = StrReplace(TrainingDescription2 & "", """", " ")
TrainingDescription2 = StrReplace(TrainingDescription2 & "", ",", "-")
TrainingDescription2 = StrReplace(TrainingDescription2 & "", "%", "-")
Print #1, "document.write('<option value=" & Chr(34) & "http://oldintranet.net/BCIntranet/hr/trainingrecords/employees/" & TrainingDescription & ".cfm" & Chr(34) & ">" & TrainingDescription2 & "');"
On Error Resume Next
DoCmd.DeleteObject acQuery, "Qry_Employee_Training0"
On Error GoTo Main_GENTEMP_Err
strSQL = "SELECT [ISO Required Training Descriptions].[Training Description], [ISO Required Training Descriptions].IDisotraining, [Training Subjects].IDtrainsubject, Employee.[Clock Number], [Employee Training].Date, Employee.FName, Employee.Lname FROM Employee INNER JOIN (([ISO Required Training Descriptions] INNER JOIN [Training Subjects] ON [ISO Required Training Descriptions].IDisotraining = [Training Subjects].IDisotraining) INNER JOIN [Employee Training] ON [Training Subjects].IDtrainsubject = [Employee Training].IDtrainsubject) ON Employee.[Clock Number] = [Employee Training].[Clock Number] WHERE ((([ISO Required Training Descriptions].IDisotraining)=" & !IDisotraining & "));"
' Create new query.
Set qdf = mgrdbstrn.CreateQueryDef("Qry_Employee_Training0", strSQL)
stDocName = "RPT_Employee_Training0"
DoCmd.OutputTo acOutputReport, stDocName, acFormatHTML, "\\bciappsrv1\trainingrecords\employees\" & TrainingDescription & ".cfm", , "\\bciappsrv1\trainingrecords\employees\employeetemplate.cfm"
DoCmd.Close acReport, stDocName
.MoveNext
Loop
End With
mgrrsttrn.Close
Set mgrdbstrn = Nothing
'End mgr loop
Print #1, "document.write('</select>');"
'Print #1, "document.write('<input type=" & Chr(34) & "button" & Chr(34) & " value=" & Chr(34) & "go4" & Chr(34) & " onclick=" & Chr(34) & "go4()" & Chr(34) & ">');"
Print #1, "document.write('</form>');"
Print #1, "// end hiding contents -->"
Print #1, "</script>"
Print #1, " </tr></td>"
'-------- end of writing Mgr select list
'*************************************************************************************
Print #1, "</table>"
Print #1, ""
Print #1, "<p> </p>"
Print #1, "</body>"
Print #1, "</html>"
Close #1
MsgBox "Finished"
Main_GENTEMP_Exit:
On Error Resume Next
DoCmd.DeleteObject acQuery, "Qry_Employee_Training"
Exit Sub
Main_GENTEMP_Err:
MsgBox Error$
Resume Main_GENTEMP_Exit
Resume
End Sub
Private Sub Form_Load()
SetOption "Confirm Action Queries", "0"
SetOption "Confirm Record Changes", "0"
SetOption "Confirm Document Deletions", "0"
SetOption "Show Hidden Objects", "0"
SetOption "Show System Objects", "0"
SetOption "Show Startup Dialog Box", "0"
End Sub
Private Sub Command36_Click()
On Error GoTo Err_Command36_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Qry_Append_Blank_Training"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocName = "frm-EmployeeTraining"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria, acFormAdd
Exit_Command36_Click:
Exit Sub
Err_Command36_Click:
MsgBox Err.Description
Resume Exit_Command36_Click
End Sub
Private Sub Command38_Click()
On Error GoTo Err_Command38_Click
Dim stDocName As String
stDocName = "Qry_Append_Blank_Training"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command38_Click:
Exit Sub
Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command38_Click
End Sub
Result of code: