Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a value from another table 1

Status
Not open for further replies.

GWPhoenix

IS-IT--Management
Jun 26, 2001
32
US
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'.


Code:
Case "Select"
Response.Write &quot;<h3>Assign Applicant and Report to User</h3>&quot;
		
Response.Write &quot;<form action='assign.asp?op=Addnew' method='post' id=form1 name=form1>&quot; & vbCrLf
		
Response.Write &quot;<table>&quot; & vbCrLf
'List Applicants				
	Response.Write &quot;<tr>&quot; & vbCrLf
	Response.Write &quot;<th align='left'>Applicant:</th>&quot; & vbCrLf
	Response.Write &quot;<td>&quot; & vbCrLf
	Response.Write &quot;<SELECT NAME='Applicant'>&quot; & vbCrLf
		Response.Write &quot;<OPTION Value='Applicant One' SELECTED>Applicant One </OPTION>&quot; & vbCrLf
		Response.Write &quot;<OPTION Value='Applicant Two'>Applicant Two </OPTION>&quot; & vbCrLf
		Response.Write &quot;<OPTION Value='Applicant Three'>Applicant Three </OPTION>&quot; & vbCrLf
	Response.Write &quot;</SELECT>&quot; & vbCrLf
	Response.Write &quot;</td>&quot; & vbCrLf
	Response.Write &quot;</tr>&quot; & vbCrLf
					
'List the Question Sets 
		Response.Write &quot;<tr>&quot; & vbCrLf
		Response.Write &quot;<th valign='top' align='left'>Report:</th>&quot; & vbCrLf
		Response.Write &quot;<td>&quot; & vbCrLf
			strSQL=&quot;SELECT * FROM tblReports WHERE Active=1 ORDER BY ReportID&quot;
			rst.Open strSQL, cxn
			i=1
			do until rst.EOF
			if i=1 then 
				Selected=&quot;CHECKED&quot;
				i=0
				else
				Selected=&quot;&quot;
			end if
		Response.Write &quot;<input type='radio' name='ReportID' value='&quot; & rst(&quot;ReportID&quot;) & &quot;' &quot; & Selected & &quot;>&quot; & rst(&quot;ShortTitle&quot;) & &quot;<BR>&quot; & vbCrLf
		rst.MoveNext
		loop
			rst.Close
		Response.Write &quot;</td>&quot; & vbCrLf
		Response.Write &quot;</tr>&quot; & vbCrLf

'List the Users; select one.  From the log-in table. Role = 0 is non-admin.					
		strSQL=&quot;SELECT * FROM tblUsers WHERE Role = 0 ORDER BY UserName&quot;
		rst.Open strSQL, cxn
		Response.Write &quot;<table>&quot;
		Response.Write &quot;<tr><th>User Name</th></tr>&quot;
		Response.Write &quot;<tr><td><SELECT NAME = 'User'>&quot;
		do while not rst.EOF
		%>
		<OPTION VALUE =&quot;<%= rst(&quot;UserID&quot;)%>&quot;>
		<%= rst(&quot;UserName&quot;)%> 
		<%
			rst.MoveNext
		loop
		rst.Close			
		Response.Write &quot;</SELECT></td></tr>&quot;			
					
Response.Write &quot;<tr><td colspan='2' align='center'><input type='submit' name='sent' value='      Go      '></td></tr>&quot; & vbCrLf
Response.Write &quot;</table>&quot; & vbCrLf
Response.Write &quot;</form>&quot; & vbCrLf
		
		
Case &quot;Addnew&quot;  '-----------------------------------------------ADDNEW--------------------------------------------------------------------------------
	ReportID=Trim(Request.Form(&quot;ReportID&quot;))
	UserID=trim(Request.Form(&quot;UserID&quot;))
	Applicant=trim(Request.Form(&quot;Applicant&quot;))
			
	strSQL=&quot;SELECT ReportDataID FROM tblReportData &quot; & _
		&quot;WHERE ReportID=&quot; & ReportID & &quot; &quot; & _
		&quot;AND UserID='&quot; & UserID & &quot;'&quot; & _
		&quot;AND Applicant='&quot; & Applicant & &quot;'&quot;
		
	rst.Open strSQL,cxn
			
	if not rst.EOF then
		ReportDataID=trim(rst(&quot;ReportDataID&quot;))
	rst.Close
	set rst=Nothing
	cxn.Close
	set cxn=nothing
	
(1)	Response.Write &quot;Report &quot; & ReportID & &quot; for User &quot; & UserID & &quot; is already assigned.&quot;
	end if
	
	rst.Close 
			
	strSQL=&quot;SELECT * FROM tblReports WHERE ReportID=&quot; & ReportID
	rst.Open strSQL, cxn
			
		if not rst.EOF then
(2)			Response.Write &quot;<H2>&quot; & rst(&quot;Title&quot;) & &quot;</H2>&quot;
			Response.Write &quot;<h3>&quot; & Applicant & &quot; assigned to User &quot; & UserID & &quot;</h3>&quot;
		end if
			rst.Close 		
	
	Response.Write &quot;<form action='assign.asp?op=Insert&ReportID=&quot; & ReportID & &quot;' method='post' id=form1 name=form1>&quot;
	
	Response.Write &quot;<input type = 'hidden' name='UserID' value ='&quot; & UserID & &quot;'>&quot;
	Response.Write &quot;<input type='submit' name='' value='Assign'>&quot;
	Response.Write &quot;</form>&quot;

'	rst.Close 
	set rst=nothing
	cxn.Close
	set cxn=nothing

Case &quot;Insert&quot;  '-----------------------------------------------INSERT--------------------------------------------------------------------------------
			ReportID=trim(Request.QueryString(&quot;ReportID&quot;))
			Questions=split(Request.Form(&quot;QuestionID&quot;),&quot;,&quot;)
			Applicant=trim(Request.Form(&quot;Applicant&quot;))

			strSQL=&quot;SELECT * FROM tblReportData WHERE 1=0&quot;
			
			rst.open strSQL, cxn, 1, 3  'adOpenKeyset, adLockOptimistic
			rst.AddNew
				rst(&quot;UserID&quot;)=Request.Form(&quot;UserID&quot;)
				rst(&quot;DateCreated&quot;)=Now()
				rst(&quot;Applicant&quot;)=Applicant
				rst(&quot;ReportID&quot;)=ReportID
			rst.Update 
			
			ReportDataID=rst(&quot;ReportDataID&quot;).Value
				
(3)			Response.Write &quot;Report ID:  &quot; & ReportDataID & &quot; <BR>Report Number:  &quot; & ReportID & &quot;<BR>Applicant:  &quot; & Applicant & &quot; <BR>Assigned to User &quot; & UserID & &quot;.&quot;
	
	rst.Close 
	
End Select
	
	set rst=nothing
(4)	cxn.Close
	set cxn=nothing
 
The one thing I spot is that if this is a straight copy of your actual code this may be causing a problem.
You are setting the select name to 'User' but referencing it in the Request.Form object as 'UserID'. You might check that. As far as the cnx object error I would double check that you are not closing it somewhere to soon.

Response.Write &quot;<tr><td><SELECT NAME = 'User'>&quot;

UserID=trim(Request.Form(&quot;UserID&quot;))


If you want you could email me the full code from the page and I could take a look and see if anything jumps out at me.

rzcam@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top