 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 9th, 2004, 09:41 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
uSing dynamically list boxes
Hi
I need some help.I will be very thankful to you if you can help me. This is my program stepwise. Pls someone help me.
Note: Everytime I select an item from the combo box or select box I havea wrote function so it retuns the whole ReportTrainingType ASP page. with this function SubmitMe()
1) I have a combo box on a form which has three values. TP,SP,IP. When I select one of the value from the combobox TP, or IP or SP
2) it gives me a list of records which I populate in the Select box I have.
3) When I click on the select box item it gives me the records of the employee in that particular item. It gives me all the records.
4) I want only a certain number of records using the date fields.
5) So I kept a date field on the form and retrieve those values.
I used this function to refresh the ReportTrainingType ASP page
function SubmitMe()
{
document.TCForm.submit();
return(true);
}
' This is the initial combo box
<form method="POST" name="TCForm" action="RptTrainingbyTypeCode.asp?menuid=<%=menuid %>&typeid=<%=TType%>">
<SELECT name="TrainType" size="1" onchange="SubmitMe()">
<%
'Populate the drop down menu with training code names
response.write "<OPTION VALUE = -1> </OPTION>"
Do While NOT RST.EOF
if cint(RST("Training_Method_ID")) = TType then
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "' SELECTED>"
Response.Write RST("Training_Method_Text") & "</OPTION>"
else
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "'>"
Response.Write RST("Training_Method_Text") & "</OPTION>"
end if
RST.MoveNext
Loop
rst.close
set rst = nothing
%>
' This is the Select box where i select the item to display all the emp records.
response.write "<SELECT name='TrainCode' size='10' onclick='SubmitMe()'>"
'Go through list and write information
do while not rst.eof
WriteClass(TType)
rst.movenext
loop
response.write "</Select>"
end if
rst.close
set rst = nothing
' This where I display the all the emp records.
Set RST=Server.CreateObject("adodb.recordset")
rst.open strSQL, conn
if not rst.eof then
rst.MoveFirst
response.write "<tr><td><b>[u]Employee Name</u></b></td><td align='center'><b>[u]Date Trained</u></b></td><td><b>[u]Employee Name</u></b></td><td align='center'><b>[u]Date Trained</u></b></td></tr>"
CurrentName = -1
NameCount = 1
'Go through list and write information. Eliminate duplicates.
do while not rst.eof
if CurrentName <> rst("Employee ID") then 'Different Names. Print
if NameCount = 1 then
response.write "<tr>"
end if
Response.Write " <td width='200'>" & rst("First Name") & " " & rst("Middle Name") & " " & rst("Last Name") & "</td><td width='200' align='center'>" & rst("Training_Date") & "</td> "
if NameCount = 2 then
response.write "</tr>"
NameCount = 1
Else
NameCount = NameCount + 1
end if
CurrentName = rst("Employee ID")
' else Names are same. Do not print duplicates.
end if
rst.movenext 'Go to next record
loop
end if
rst.close
set rst = nothing
conn.close
set conn = nothing
end if
%>
Pls help me
Thanks
|
|

August 9th, 2004, 11:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If I understood that right, you are looking for filtering employee data based on the Date field.
Quote:
quote:' This where I display the all the emp records.
Set RST=Server.CreateObject("adodb.recordset")
rst.open strSQL, conn
|
What is the query you use in your strSQL? Can you post that? Looks like there should be something added to the query to get that result.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

August 10th, 2004, 08:35 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
This is the whole code i am using.
<%
'Initialize variables
Dim conn 'Link to database
Dim strSQL 'All
Dim rst 'Record set of all training codes that can be accessed
Dim code 'Training code of currently selected type
Dim ClassTitle 'Title of Current Training
%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Language" CONTENT="en-us">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<script language="javascript">
function SubmitMe()
{
document.DForm.submit();
document.TCForm.submit();
return(true);
}
function DSubmitMe()
{
document.DForm.submit();
return(true);
}
function GetTrainingCode()
{
alert (window.document.TCForm.SaveCode.value);
return(true);
}
function GetTraining()
{
alert (window.document.DForm.SaveCode.value);
return(true);
}
</Script>
<TITLE>Training by Type</TITLE>
</HEAD>
<BODY TEXT="#510000" LINK="#999900" VLINK="#CC9966" ALINK="#990066" >
<Table Cellspacing=0 border="0" cellpadding="0" width="800" height="52">
<tr><td width="149" height="46" valign="top"><img border="0" src="images/Metrics_Heading.png" width="149" height="46"></td><td width="651" height="46" valign="bottom" align="center"><b>Training
by Type
</b>
</td></tr>
<tr><td colspan="2" width="800" height="16"> <img border="0" src="images/Heading_LineInc.gif"> </td>
</Table>
<%
if request.Querystring("typeid") <> "" and not isnull(request.querystring("typeid")) then
TType = cint(Request.querystring("typeid"))
else
TType = -1
end if
if request.Querystring("classid") <> "" and not isnull(request.querystring("classid")) then
Class_ID = cint(Request.querystring("classid"))
else
Class_ID = -1
end if
Response.Write "kumar3"
menuid = request.querystring("menuid")
' Create an ADO Connection to connect to the sample database.
set conn = Server.CreateObject("ADODB.Connection")
'Use ODBC DSN to link to MS Access database
conn.open "DSN=Metrics;uid=" & session("Userid") & ";pwd=" & session("Password")
Set RST=Server.CreateObject("adodb.recordset")
strSQL = "Select * from training_method Where (training_method_ID > 0 and training_method_id < 4) or (training_method_id > 8 and training_method_id < 12) order by training_method_ID ;"
rst.open strSQL, conn
rst.MoveFirst
StartDate = request.Form("BeginMonth") & "/" & request.Form("BeginDay") & "/" & request.Form("BeginYear")
if len(StartDate) > 2 then
'Get date values entered in fields
StartDate = DateValue(StartDate)
EndDate = DateValue(request("EndDateMonth") & "/" & request("EndDateDay") & "/" & request("EndDateYear"))
'Set date values that are displayed on form
EDate = EndDate
BDate = StartDate
FirstTime = False
else
FirstTime = True
EDate = now()
'EDate = DateValue(rst("Training_Date"))
'rst.movelast
'BDate = DateValue(rst("Training_Date"))
end if
Response.Write StartDate
%>
<form method="POST" name="TCForm" action="RptTrainingbyTypeCode.asp?menuid=<%=menuid %>&typeid=<%=TType%>">
<table cellspacing="0" cellpadding="0" width="792">
<td valign=" width="50%" top" width="135">
<b>Training Type:</b>
<td valign="top" width="657">
<SELECT name="TrainType" size="1" onchange="SubmitMe()">
<%
'Populate the drop down menu with training code names
response.write "<OPTION VALUE = -1> </OPTION>"
Do While NOT RST.EOF
if cint(RST("Training_Method_ID")) = TType then
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "' SELECTED>"
Response.Write RST("Training_Method_Text") & "</OPTION>"
else
Response.Write "<OPTION VALUE='" & RST("Training_Method_ID") & "'>"
Response.Write RST("Training_Method_Text") & "</OPTION>"
end if
RST.MoveNext
Loop
rst.close
set rst = nothing
%>
</SELECT>
</Table>
<Table>
<%
'************************************************* ***********************************************
'Spacing for the display
'CName - Text field used to pad with blanks
'CLength - Total Length of Space in Field
'************************************************* ***********************************************
Function GetBlanks (CName, CLength)
Dim SpacesNeeded 'Number of spaces needed
SpacesNeeded = Clength - Len(CName)
Select Case SpacesNeeded
Case 1: GetBlanks = CName & " "
Case 2: GetBlanks = CName & " "
Case 3: GetBlanks = CName & " "
Case 4: GetBlanks = CName & " "
Case 5: GetBlanks = CName & " "
Case 6: GetBlanks = CName & " & nbsp; "
Case 7: GetBlanks = CName & " & nbsp; "
Case 8: GetBlanks = CName & " & nbsp; &nb sp;"
Case 9: GetBlanks = CName & " & nbsp; &nb sp; "
Case 10: GetBlanks = CName & " & nbsp; &nb sp; "
Case 11: GetBlanks = CName & " & nbsp; &nb sp; "
Case 12: GetBlanks = CName & " & nbsp; &nb sp;   ; "
Case 13: GetBlanks = CName & " & nbsp; &nb sp;   ; "
Case 14: GetBlanks = CName & " & nbsp; &nb sp;   ; "
Case 15: GetBlanks = CName & " & nbsp; &nb sp;   ; "
Case 16: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; "
Case 17: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; "
Case 18: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; "
Case 19: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 20: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 21: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 22: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 23: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ;"
Case 24: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 25: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 26: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; "
Case 27: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; "
Case 28: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; "
Case 29: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; "
Case 30: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 31: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 32: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 33: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 34: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 35: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 36: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 37: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 38: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 39: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp; "
Case 40: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ;"
Case 41: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 42: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 43: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 44: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 45: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 46: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 47: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; "
Case 48: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ;   ;"
Case 49: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp;"
Case 50: GetBlanks = CName & " & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; "
Case Else: GetBlanks = CName
End Select
End Function
Sub WriteHeader(ClassCode)
'************************************************* ************************************************** *********
'Writes class header information for each class based on class type.
'Input: ClassCode - type of class as a string numeric value
'************************************************* ************************************************** *********
Select Case ClassCode
Case "1": 'SOP Header
Response.Write "<TR ><TD ALIGN=left valign=top><B><U>ID</U></B> <B><U>Title</U></B></TD></TR>"
Case "2" : 'TP Header
Response.Write "<tr><td align=left valign=top><B><U>ID</U></B> <B><U>Title </U></B></td></tr>"
Case "3" : 'Internal Class Header
Response.Write "<TR ><TD ALIGN=left valign=top><B><U>ID</U></B> <B><U>Traini ng Type</U></B> <B><U>Title</U></B></TD></TR>"
Case "9" : 'SHEP Header
Response.Write "<TR ><TD ALIGN=left valign=top ><B><U>ID</U></B> <B><U>Title</U></B></TD></TR>"
Case "10": 'Client SOP Header
Response.Write "<TR ><TD ALIGN=left valign=top><B><U>ID</U></B> &n bsp; &nbs p; &n bsp; &nbs p; <B><U>Title</U></B></TD></TR>"
Case "11": 'Client Method Header
Response.Write "<TR ><TD ALIGN=left valign=top><B><U>ID</U></B> &n bsp; &nbs p; &n bsp; &nbs p; <B><U>Ti tle</U></B></TD></TR>"
end select
end sub
'************************************************* ************************************************** *********
'Writes class information for each class based on class type.
'Input: ClassCode - type of class as a string numeric value
'************************************************* ************************************************** *********
Sub WriteClass(ClassCode)
Select Case ClassCode
Case "1": 'SOP Method
'Write the Client Code number
if isnull(rst("Type_ID")) or (rst("Type_ID") = "") then
TypeID = " "
else
TypeID = rst("Type_ID")
end if
if isnull(rst("SOP_ID_NUM")) or (rst("SOP_ID_NUM") = "") THEN
SOPIDNUM = " &nb sp;"
else
SOPIDNUM = rst("SOP_ID_NUM")
end if
Response.Write "<OPTION VALUE='" & rst("SOP_ID") & "'>"
Response.Write TypeID & " " & SOPIDNUM & " " & rst("Title") & "</OPTION>"
Case "2": 'TP Method
'Write the TP Method list
Response.Write "<OPTION VALUE='" & rst("TP_ID") & "'>"
response.write "TP " & rst("TP_ID_Num") & " & nbsp;" & rst("Title") & "</OPTION>"
Case "3": 'Internal Class
'Write the Internal Class list
TrainingTypeText = GetBlanks(trim(rst("Training_Type_Text")), 20)
Response.Write "<OPTION VALUE='" & rst("Class_ID") & "'>"
response.write rst("Class_ID_Num") & " &nb sp;" & TrainingTypeText & rst("Class_Title") & "</Option>"
Case "9": 'SHEP Training
'Write the SHEP Method list
Response.Write "<OPTION VALUE='" & rst("SHEP_ID") & "'>"
response.write rst("Type_ID") & " " & rst("Shep_ID_NUM") & " " & rst("Title") & "</OPTION>"
Case "10": 'Client SOP Method
ClientCode = GetBlanks(trim(rst("code") & " " & rst("SOP_ID_NUM")), 40)
'Write the Client Code number
Response.Write "<OPTION VALUE='" & rst("SOP_ID") & "'>"
response.write ClientCode & rst("Title") & "</OPTION>"
Case "11": 'Client Method
'Write the Client Method list
ClientCode = GetBlanks(trim(rst("code") & " " & rst("Method_ID_NUM")), 40)
Response.Write "<OPTION VALUE='" & rst("METHOD_ID") & "'>"
response.write ClientCode & rst("Title") & "</OPTION>"
End Select
End Sub
if TType > 0 then 'If code selected write instructions.
response.write "<i>Click on the title below to see which employees have been trained:"
end if
if TType > 0 then
Set RST=Server.CreateObject("adodb.recordset")
strSQL = "Select Training_Method_Text from training_method where Training_Method_ID = " & TType
rst.open strSQL, conn 'Get the list of Classes employee has taken
rst.MoveFirst 'Move to the first record in the list
if not rst.eof then 'If a record is in the list
MethodType = rst("Training_Method_Text")
end if
rst.close
set rst = nothing
end if
Set RST=Server.CreateObject("adodb.recordset")
if TType > 0 then
Select case TType
Case 1: 'SOP method
strSQL = "Select sop.SOP_ID, sop.Type_ID, sop.SOP_ID_NUM, sop.Client_ID, sop.Title, sop.Status_ID, sop.Revision_Code, doc_status.Status_Text from employee RIGHT JOIN (doc_status RIGHT JOIN sop ON doc_status.Status_ID = sop.Status_ID) on employee.[Employee ID] = sop.Author_ID WHERE (((sop.Client_ID) is Null)) AND sop.Status_ID = 1 Order by sop.Type_ID, sop.SOP_ID_NUM;"
Case 2: 'TP method
strSQL = "Select tp.TP_ID, tp.TP_ID_Num, tp.Revision_Code, tp.Status_ID, tp.Title, doc_status.Status_Text from doc_status RIGHT JOIN tp ON doc_status.Status_ID = tp.Status_ID WHERE tp.Status_ID = 1 Order by tp.tp_ID;"
Case 3: 'Internal Class
strSQL = "Select class.Class_ID, class.Class_ID_Num, class.Class_Title, training_type.Training_Type_Text from training_type INNER JOIN class on training_type.Training_Type_ID = class.Training_Type_ID Order by training_type.Training_Type_Text;"
Case 9: 'SHEP
strSQL = "Select shep.Shep_ID, shep.Revision_Code, shep.Title, shep.Type_ID, shep.shep_ID_NUM, doc_status.Status_Text from doc_status RIGHT JOIN shep ON doc_status.Status_ID = shep.Status_ID WHERE shep.Status_ID = 1 ORDER BY Status_Text, Type_ID, SHEP_ID_NUM;"
Case 10: 'Client SOP
strSQL = "Select sop.SOP_ID, sop.SOP_ID_NUM, sop.Client_ID, client_codes.Code, client_codes.[Client Name], sop.Title, sop.Revision_Code, doc_status.Status_Text from doc_status RIGHT JOIN (client_codes RIGHT JOIN sop ON client_codes.ID = sop.Client_ID) ON doc_status.Status_ID = sop.Status_ID WHERE (((sop.Client_ID) is Not Null)) AND sop.Status_ID = 1 Order by code, sop_id_num;"
Case 11: 'Client Method
strSQL = "Select methods.Method_ID, methods.Method_ID_NUM, methods.Revision_Code, doc_status.Status_Text, client_codes.Code, client_codes.[Client Name], methods.Title from (methods LEFT JOIN doc_status ON methods.Status_ID = doc_status.Status_ID) LEFT JOIN client_codes ON methods.Client_ID=client_codes.ID Where methods.Status_ID = 1 Order BY client_codes.Code, methods.Method_ID_NUM;"
End select
rst.open strSQL, conn
rst.MoveFirst 'Move to the first record in the list
if not rst.eof then 'If a record is in the list
'Print heading
response.write "<br><br>"
response.write "<Table>"
Response.Write "<TR bgcolor='#DEDEEF'><TD COLSPAN=12 ALIGN=left width='800'><B>" & methodtype & "s</B></TD></TR>"
WriteHeader (TType)
response.write "</Table>"
response.write "<SELECT name='TrainCode' size='10' onchange='SubmitMe()'>"
'Go through list and write information
do while not rst.eof
WriteClass(TType)
rst.movenext
loop
response.write "</Select>"
end if
rst.close
set rst = nothing
response.write "<br><br>"
response.write "</Table>"
if Class_ID > 0 then
Class_ID=cint(Request.Querystring("classid"))
end if
If Class_ID > 0 then
Select Case TType
Case 1: 'SOP
strSQL = "Select sop.Title, [Type_ID] & ' ' & [SOP_ID_NUM] as ID_Num from sop where sop_ID = " & Class_ID & ";"
Case 2: 'TP
strSQL = "Select tp.Title, 'TP ' & tp.TP_ID_Num as ID_Num from tp where TP_ID = " & Class_ID & ";"
Case 3: 'Internal Class
strSQL = "Select class.Class_Title as Title, class.Class_ID_Num as ID_Num from class where Class_ID = " & Class_ID & ";"
Case 9: 'SHEP
strSQL = "Select shep.Title, shep.Type_ID & ' ' & shep.shep_ID_NUM as ID_Num from shep where Shep_ID = " & Class_ID & ";"
Case 10: 'Client SOP
strSQL = "Select sop.Title, client_codes.Code & ' ' & sop.SOP_ID_NUM as ID_Num from sop LEFT JOIN client_codes ON sop.Client_ID = client_codes.ID where sop_ID = " & Class_ID & ";"
Case 11: 'Client Method
strSQL = "Select methods.Title, client_codes.Code & ' ' & methods.Method_ID_NUM as ID_Num from methods INNER JOIN client_codes ON methods.Client_ID = client_codes.ID where Method_ID = " & Class_ID & ";"
Case else:
strSQL = ""
end select
Set RST=Server.CreateObject("adodb.recordset")
rst.open strSQL, conn
if not rst.eof then
rst.MoveFirst
if trim(rst("ID_NUM")) = "" or isnull(rst("ID_NUM")) then
ClassTitle = rst("Title")
else
ClassTitle = rst("ID_NUM") & " " & rst("Title")
end if
end if
rst.close
set rst = nothing
end if
if Session("SecurityLvl") < 3 then 'Not Supervisor
strSQL = "SELECT employee.[Employee ID], employee.[First Name], employee.[Middle Name], employee.[Last Name], employee_training.Training_Method_ID, "
strSQL = strSQL & " employee_training.Train_ID, employee_training.Training_Date FROM "
strSQL = strSQL & "employee INNER JOIN employee_training ON employee.[Employee ID] = employee_training.Employee_ID "
strSQL = strSQL & "WHERE (((employee_training.Training_Method_ID)=" & TType & ") AND ((employee_training.Train_ID)=" & Class_ID & ")) ORDER BY employee.[Last Name], employee.[First Name], employee_training.training_date DESC;"
else 'Supervisor
SupervisorID = session("EmployeeID")
strSQL = "SELECT employee.[Employee ID], employee.[First Name], employee.[Middle Name], employee.[Last Name], employee_training.Training_Method_ID, "
strSQL = strSQL & " employee_training.Train_ID, employee_training.Training_Date FROM "
strSQL = strSQL & "employee INNER JOIN employee_training ON employee.[Employee ID] = employee_training.Employee_ID "
strSQL = strSQL & "WHERE (((employee_training.Training_Method_ID)=" & TType & ") AND ((employee_training.Train_ID)=" & Class_ID & ")) AND (employee.[Supervisor ID] =" & SupervisorID & " OR employee.[Employee ID]=" & SupervisorID & ") ORDER BY employee.[Last Name], employee.[First Name], employee_training.training_date DESC;"
end if
%>
</Table>
<table Cellspacing=0 border="0" cellpadding="0">
<%
response.write "<tr><td colspan='8'> </td></tr>"
response.write "<tr><td colspan='8'><b>" & ClassTitle & "</b></td></tr>"
response.write "<tr><td colspan='8'> </td></tr>"
Set RST=Server.CreateObject("adodb.recordset")
rst.open strSQL, conn
if not rst.eof then
rst.MoveFirst
response.write "<tr><td><b>[u]Employee Name</u></b></td><td align='center'><b>[u]Date Trained</u></b></td><td><b>[u]Employee Name</u></b></td><td align='center'><b>[u]Date Trained</u></b></td></tr>"
CurrentName = -1
NameCount = 1
'Go through list and write information. Eliminate duplicates.
do while not rst.eof
if CurrentName <> rst("Employee ID") then 'Different Names. Print
if NameCount = 1 then
response.write "<tr>"
end if
rec_Training_Date=DateValue(rst("Training_Date"))
Response.Write rec_Training_Date
Response.Write StartDate
if (rec_Training_Date>=StartDate AND rec_Training_Date<=EndDate ) then
Response.Write " <td width='200'>" & rst("First Name") & " " & rst("Middle Name") & " " & rst("Last Name") & "</td><td width='200' align='center'>" & rst("Training_Date") & "</td> "
else
'Response.Write " <td width='200'>" & rst("First Name") & " " & rst("Middle Name") & " " & rst("Last Name") & "</td><td width='200' align='center'>" & rst("Training_Date") & "</td> "
end if
if NameCount = 2 then
response.write "</tr>"
NameCount = 1
Else
NameCount = NameCount + 1
end if
CurrentName = rst("Employee ID")
' else Names are same. Do not print duplicates.
end if
rst.movenext 'Go to next record
loop
end if
rst.close
set rst = nothing
conn.close
set conn = nothing
end if
%>
<input type="hidden" name="CID" value="<% =request.Form("TrainCode") %>">
</table>
</form>
<form method="POST" name="DForm">
<p>   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;   ; & nbsp; &nb sp;
Start Date:</b> <input type="text" name="BeginMonth" size="2" value=<%=Month(BDate)%> tabindex="1" maxlength="2" onchange="return CheckMonth(BeginMonth.value)">
/ <input type="text" name="BeginDay" size="2" value=<%=Day(BDate)%> tabindex="2" maxlength="2" onchange="return CheckDay(BeginDay.value)">
/ <input type="text" name="BeginYear" size="4" value=<%=Year(BDate)%> tabindex="3" maxlength="4" onchange="return CheckYear(BeginYear.value)"> &nbs p; <b>End Date: </b><input type="text" name="EndDateMonth" size="2" value=<%=Month(EDate)%> tabindex="4" maxlength="2" onchange="return CheckMonth(EndDateMonth.value)">
/ <input type="text" name="EndDateDay" size="2" value=<%=Day(EDate)%> tabindex="5" maxlength="2" onchange="return CheckDay(EndDateDay.value)">
/ <input type="text" name="EndDateYear" size="4" value=<%=Year(EDate)%> tabindex="6" maxlength="4" onchange="return CheckYear(EndDateYear.value)"> &n bsp;
<input type="button" value=" Filter " name="BtnFilter" onClick= "DSubmitMe()"> </p>
</form>
<a href=<%=Get_Menu(menuid)%>><img border="0" src="images/B_Return_Off.gif" onclick=history.go(-1) onmouseover="src='images/B_Retu
|
|

August 11th, 2004, 01:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
hmmm... that is so easy to post the entire code. But hard to find what was actually required.
Now it is my job to find that out.
It really made me relook into my previous post to see what I had asked for.
I believe, I had asked for only the SQL statement.
Don't just post all of the code here, as it makes the page look so cluttered and one would never
be happy in this world to see someone's code and find what it does, unless it is well documented.
And this would never help in narrowing down the problem easily, rather would result in people
asking for what is that you do here and there.
Sorry, I don't think guys would have all that time free to go through your entire code unless it required to have a look into it.
And my hand is refusing to move the mouse right and left/up and down throughout the page/I have no such big monitor.
Quote:
quote:3) When I click on the select box item it gives me the records of the employee in that particular item. It gives me all the records.
4) I want only a certain number of records using the date fields.
5) So I kept a date field on the form and retrieve those values.
|
If you could find the sql statement that is related to these points, please post. Then lets ask for something, if any required.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

August 11th, 2004, 08:10 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
Sorry for psoting the whole code. Please let me know thanks.
Well. I will try to make it brief. I cannot retrieve the Date field values. I can retrieve them only when i click on the Filter button in the Form: DForm
<html>
<head>
<script language=javascript>
function SubmitMe()
{
document.TCForm.BeginMonth.value=document.DForm.Be ginMonth.value
document.TCForm.BeginDay.value=document.DForm.Begi nDay.value
document.TCForm.BeginYear.value=document.DForm.Beg inYear.value
document.TCForm.EndDateMonth.value=document.DForm. EndDateMonth.value
document.TCForm.EndDateDay.value=document.DForm.En dDateDay.value
document.TCForm.EndDateYear.value=document.DForm.E ndDateYear.value
document.TCForm.submit();
return(true);
}
</script>
</head>
<body>
StartDate = request.Form("BeginMonth") & "/" & request.Form("BeginDay") & "/" & request.Form("BeginYear")
'Get date values entered in fields
StartDate = DateValue(StartDate)
EndDate = DateValue(request("EndDateMonth") & "/" & request("EndDateDay") & "/" & request("EndDateYear"))
<form method="post" name="TCForm" action="RptTrainingbyTypeCode.asp?menuid=<%=menuid %>&typeid=<%=TType%>">>
This is where I have the combo box, select box.
' This is the query I used.
strSQL = "SELECT employee.[Employee ID], employee.[First Name], employee.[Middle Name], employee.[Last Name], employee_training.Training_Method_ID, "
strSQL = strSQL & " employee_training.Train_ID, employee_training.Training_Date FROM "
strSQL = strSQL & "employee INNER JOIN employee_training ON employee.[Employee ID] = employee_training.Employee_ID "
strSQL = strSQL & "WHERE (((employee_training.Training_Method_ID)=" & TType & ") AND ((employee_training.Train_ID)=" & Class_ID & ")) ORDER BY employee.[Last Name], employee.[First Name], employee_training.training_date DESC;"
' This is the condition where i check the date fields
if (rec_Training_Date>=StartDate AND rec_Training_Date<=EndDate ) then
Response.Write " <td width='200'>" & rst("First Name") & " " & rst("Middle Name") & " " & rst("Last Name") & "</td><td width='200' align='center'>" & rst("Training_Date") & "</td> "
</form>
<form method="POST" name="DForm">
Start Date:</b> <input type="text" name="BeginMonth" size="2" value=<%=Month(BDate)%> tabindex="1" maxlength="2" onchange="return CheckMonth(BeginMonth.value)">
/ <input type="text" name="BeginDay" size="2" value=<%=Day(BDate)%> tabindex="2" maxlength="2" onchange="return CheckDay(BeginDay.value)">
/ <input type="text" name="BeginYear" size="4" value=<%=Year(BDate)%> tabindex="3" maxlength="4" onchange="return CheckYear(BeginYear.value)"> &nbs p; <b>End Date: </b><input type="text" name="EndDateMonth" size="2" value=<%=Month(EDate)%> tabindex="4" maxlength="2" onchange="return CheckMonth(EndDateMonth.value)">
/ <input type="text" name="EndDateDay" size="2" value=<%=Day(EDate)%> tabindex="5" maxlength="2" onchange="return CheckDay(EndDateDay.value)">
/ <input type="text" name="EndDateYear" size="4" value=<%=Year(EDate)%> tabindex="6" maxlength="4" onchange="return CheckYear(EndDateYear.value)"> &n bsp;
<input type="submit" value=" Filter " name="BtnFilter" onClick="SubmitMe()"> </p>
</form>
</body>
</html>
|
|

August 13th, 2004, 06:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If I am right, this should work.
Code:
strSQL = "SELECT employee.[Employee ID], employee.[First Name], employee.[Middle Name], employee.[Last Name], employee_training.Training_Method_ID, "
strSQL = strSQL & " employee_training.Train_ID, employee_training.Training_Date FROM "
strSQL = strSQL & " employee INNER JOIN employee_training ON employee.[Employee ID] = employee_training.Employee_ID "
strSQL = strSQL & " WHERE employee_training.Training_Method_ID=" & TType & " AND employee_training.Train_ID=" & Class_ID & "
strSQL = strSQL & " AND employee_training.Training_Date BETWEEN #" & StartDate & "# AND #" & EndDate & "#"
strSQL = strSQL & " ORDER BY employee.[Last Name], employee.[First Name], employee_training.training_date DESC;"
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |