Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: let user change their info in Access via ASP - record selected by cookie


Message #1 by gary.routh2@v... on Fri, 14 Mar 2003 03:08:38
Hi all,
I'm writing an asp page that looks up the member's ID from a cookie and 
then selects the record from the Access database for that member ID.   I 
want to display those fields (Fname, Lname, Email and many others that I 
have cut from the code below)in text boxes where the member can change the 
values and submit the changed data to the database.

I'm really clueless about how to display the data from the recordset in 
the text box.  Should be very simple.

Using the code below, I get a message that Object doesn't support this 
property or method.  form.txtFName.  

Please help!

Thank you.

<html>
<head>
      <!-- CONTENT START -->
<form action=EditMyInfoConfirmation.asp method=post name=frmEditMyInfo>
<table width="715">
...
	<td width="96">First Name</td>
	<td width="245"><input type=text name=txtFName size=15></td>
	<td width="78">Last Name</td>
	<td width="274"><input type=text name=txtLName size=18></td>

	<td width="96">E-mail address</td>
	<td width="245"><input type=text name=txtEmail size=30></td>
...	
	<td width="96"><input type=button name=btnSubmit value=Submit></td>
...
	</tr>
</form>
      
	<!-- #include file="Connect.inc" -->

<%
DIM varCookieHolder
varCookieHolder = Request.Cookies("SOF")("ID")
'Check for database errors
Call CheckForErrors(objConn)
Response.Write(varCookieHolder)

'Create the recordset object, set the SQL string and open the recordset
 Set objRS = Server.CreateObject("ADODB.Recordset")
 objRS.Open "SELECT * FROM MEMBERS WHERE MEMBERS.ID=" & varCookieHolder 
&";", "DSN=SOF"
 objRS.movefirst
'Check for database errors
 Call CheckForErrors(objConn)
 If objRS.EOF or objRS.BOF Then
    Session("ErrorMessage")= "No record found."
 Else
    Session("ErrorMessage")= Empty
 End If

DIM varLName, varFName, varEMail
varLName=objRS("LName")
varFName=objRS("FName")
varEMail=objRS("EMail")
%>

 Sub Window_OnLoad()
    form.txtFName.value = varFName
    form.input.txtLName.value = varLName
    form.input.txtEmail.value = varEMail

<!-- #include file="Disconnect.inc" -->

' clean up all declared variables	
	
 End Sub

Sub btnSubmit_OnClick()
	'Verify all required fields have been entered - pad w/blank if not 
required
	If Len(frmRegister.txtFName.value) = 0 Then
		Alert "You must enter a first name"
		frmRegister.txtFirstName.focus
		Exit Sub
	ElseIf Len(frmRegister.txtLName.value) = 0 Then
		Alert "You must enter a last name"
		frmRegister.txtLName.focus
		Exit Sub
	ElseIf Len(frmRegister.txtemail.value) = 0 Then
		Alert "You must enter an email address"
		frmRegister.txtemail.focus
		Exit Sub
	End If
	
	'If we get to this point all is OK, submit the form
	Call frmEditMyInfo.submit()
End Sub
    </script>
</table>
</BODY>
      <!-- CONTENT END -->
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 14 Mar 2003 14:47:44 +1100
<input type="text" name="txtFirstName"
value="<%=objRS.Fields("FirstName").Value%>">

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <gary.routh2@v...>
Subject: [access_asp] let user change their info in Access via ASP - record
selected by cookie


: Hi all,
: I'm writing an asp page that looks up the member's ID from a cookie and
: then selects the record from the Access database for that member ID.   I
: want to display those fields (Fname, Lname, Email and many others that I
: have cut from the code below)in text boxes where the member can change the
: values and submit the changed data to the database.
:
: I'm really clueless about how to display the data from the recordset in
: the text box.  Should be very simple.
:
: Using the code below, I get a message that Object doesn't support this
: property or method.  form.txtFName.
:
: Please help!
:
: Thank you.

Message #3 by gary.routh2@v... on Mon, 17 Mar 2003 03:14:57
Exactly what I needed!  Thanks for your wonderful help!
Gary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> <input type="text" name="txtFirstName"
value="<%=objRS.Fields("FirstName").Value%>">

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <gary.routh2@v...>
Subject: [access_asp] let user change their info in Access via ASP - record
selected by cookie


: Hi all,
: I'm writing an asp page that looks up the member's ID from a cookie and
: then selects the record from the Access database for that member ID.   I
: want to display those fields (Fname, Lname, Email and many others that I
: have cut from the code below)in text boxes where the member can change 
the
: values and submit the changed data to the database.
:
: I'm really clueless about how to display the data from the recordset in
: the text box.  Should be very simple.
:
: Using the code below, I get a message that Object doesn't support this
: property or method.  form.txtFName.
:
: Please help!
:
: Thank you.


  Return to Index