I have a form where the Administrator selects an Applicant (in hard-coded drop-down), Report (Radio Button), and which user will do the specific report; the users coming from the log-in table. This moves me to subroutine AddNew, where I will either be informed that this specific report is already assigned to someone else (1) or kick back the name of the Applicant, Report and to whom I am proposing it be assigned (2), along with an "Assign" button.
In case of (2), when I click on the "Assign" button, I want to fill in the table "tblReportData" with the UserID, Applicant, Report ID (from the Radio Buttons), and UserID, then print a verification.(3)
WHAT IS NOT HAPPENING centers mostly around UserID. This value does not seem to pass from one table to the next.
At (2) I get no value for UserID at all and an error error '800a01a8' Object required: 'cxn' that refers to (4), although I do get the Assign button.
By the time it shows up in (3), the value is the Username is the UserID defined in my include file 'cxn.asp'.
In case of (2), when I click on the "Assign" button, I want to fill in the table "tblReportData" with the UserID, Applicant, Report ID (from the Radio Buttons), and UserID, then print a verification.(3)
WHAT IS NOT HAPPENING centers mostly around UserID. This value does not seem to pass from one table to the next.
At (2) I get no value for UserID at all and an error error '800a01a8' Object required: 'cxn' that refers to (4), although I do get the Assign button.
By the time it shows up in (3), the value is the Username is the UserID defined in my include file 'cxn.asp'.
Code:
Case "Select"
Response.Write "<h3>Assign Applicant and Report to User</h3>"
Response.Write "<form action='assign.asp?op=Addnew' method='post' id=form1 name=form1>" & vbCrLf
Response.Write "<table>" & vbCrLf
'List Applicants
Response.Write "<tr>" & vbCrLf
Response.Write "<th align='left'>Applicant:</th>" & vbCrLf
Response.Write "<td>" & vbCrLf
Response.Write "<SELECT NAME='Applicant'>" & vbCrLf
Response.Write "<OPTION Value='Applicant One' SELECTED>Applicant One </OPTION>" & vbCrLf
Response.Write "<OPTION Value='Applicant Two'>Applicant Two </OPTION>" & vbCrLf
Response.Write "<OPTION Value='Applicant Three'>Applicant Three </OPTION>" & vbCrLf
Response.Write "</SELECT>" & vbCrLf
Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
'List the Question Sets
Response.Write "<tr>" & vbCrLf
Response.Write "<th valign='top' align='left'>Report:</th>" & vbCrLf
Response.Write "<td>" & vbCrLf
strSQL="SELECT * FROM tblReports WHERE Active=1 ORDER BY ReportID"
rst.Open strSQL, cxn
i=1
do until rst.EOF
if i=1 then
Selected="CHECKED"
i=0
else
Selected=""
end if
Response.Write "<input type='radio' name='ReportID' value='" & rst("ReportID") & "' " & Selected & ">" & rst("ShortTitle") & "<BR>" & vbCrLf
rst.MoveNext
loop
rst.Close
Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
'List the Users; select one. From the log-in table. Role = 0 is non-admin.
strSQL="SELECT * FROM tblUsers WHERE Role = 0 ORDER BY UserName"
rst.Open strSQL, cxn
Response.Write "<table>"
Response.Write "<tr><th>User Name</th></tr>"
Response.Write "<tr><td><SELECT NAME = 'User'>"
do while not rst.EOF
%>
<OPTION VALUE ="<%= rst("UserID")%>">
<%= rst("UserName")%>
<%
rst.MoveNext
loop
rst.Close
Response.Write "</SELECT></td></tr>"
Response.Write "<tr><td colspan='2' align='center'><input type='submit' name='sent' value=' Go '></td></tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Response.Write "</form>" & vbCrLf
Case "Addnew" '-----------------------------------------------ADDNEW--------------------------------------------------------------------------------
ReportID=Trim(Request.Form("ReportID"))
UserID=trim(Request.Form("UserID"))
Applicant=trim(Request.Form("Applicant"))
strSQL="SELECT ReportDataID FROM tblReportData " & _
"WHERE ReportID=" & ReportID & " " & _
"AND UserID='" & UserID & "'" & _
"AND Applicant='" & Applicant & "'"
rst.Open strSQL,cxn
if not rst.EOF then
ReportDataID=trim(rst("ReportDataID"))
rst.Close
set rst=Nothing
cxn.Close
set cxn=nothing
(1) Response.Write "Report " & ReportID & " for User " & UserID & " is already assigned."
end if
rst.Close
strSQL="SELECT * FROM tblReports WHERE ReportID=" & ReportID
rst.Open strSQL, cxn
if not rst.EOF then
(2) Response.Write "<H2>" & rst("Title") & "</H2>"
Response.Write "<h3>" & Applicant & " assigned to User " & UserID & "</h3>"
end if
rst.Close
Response.Write "<form action='assign.asp?op=Insert&ReportID=" & ReportID & "' method='post' id=form1 name=form1>"
Response.Write "<input type = 'hidden' name='UserID' value ='" & UserID & "'>"
Response.Write "<input type='submit' name='' value='Assign'>"
Response.Write "</form>"
' rst.Close
set rst=nothing
cxn.Close
set cxn=nothing
Case "Insert" '-----------------------------------------------INSERT--------------------------------------------------------------------------------
ReportID=trim(Request.QueryString("ReportID"))
Questions=split(Request.Form("QuestionID"),",")
Applicant=trim(Request.Form("Applicant"))
strSQL="SELECT * FROM tblReportData WHERE 1=0"
rst.open strSQL, cxn, 1, 3 'adOpenKeyset, adLockOptimistic
rst.AddNew
rst("UserID")=Request.Form("UserID")
rst("DateCreated")=Now()
rst("Applicant")=Applicant
rst("ReportID")=ReportID
rst.Update
ReportDataID=rst("ReportDataID").Value
(3) Response.Write "Report ID: " & ReportDataID & " <BR>Report Number: " & ReportID & "<BR>Applicant: " & Applicant & " <BR>Assigned to User " & UserID & "."
rst.Close
End Select
set rst=nothing
(4) cxn.Close
set cxn=nothing