|
 |
access_asp thread: Submit Records without leaving Form Page
Message #1 by jmendez@k... on Mon, 25 Nov 2002 18:08:06
|
|
I have an asp code that I am trying to build on from a sample that I read
in a book. I am trying to enter table data, submit a record to a table,
clear the form, and then be ready to enter data for next record.
Continuous data entry without leaving the screen. I hope that somebody
can help me out.
Thank You. Below is my code.
<% Option Explicit %>
<!-- #include virtual="common/adovbs.inc" -->
<html>
<head>
<title>Enter New Project Information</title>
</head>
<body bgcolor="#ffffff" vlink=black>
<!-- #include file="header.inc" --><p>
<%
If Request("ProjNbr")="" Or Request("Description")="" Or _
Request("ProjectName")="" Or Request("WaterSystem")="" Or _
Request("Location")="" Or Request("Proj_Mgr")="" Then
%>
<% ShowHeader "Enter New Project" %>
Please fill in all of these fields below. <p>
When you are finished, click the Submit Record button.<p>
<form method="post" action="placead.asp" name="ProjAdd" >
<table>
<tr><td>Project Number:</td>
<td><input size="50" name="ProjNbr" ></td></tr>
<TR><td valign=top>Project Name:</td>
<td><input size=50 name="ProjectName" ></td></TR>
<TR><td valign=top>Description:</td>
<td><TEXTAREA cols=50 name="Description" rows=6></TEXTAREA></td></TR>
<tr><td>Water System:</td>
<td> <select name="WaterSystem" size="1">
<option selected value="Lihue">Lihue-Hanamaulu</option>
<option value="Kapaa">Wailua-Kapaa</option>
<option value="Koloa">Koloa-Poipu</option>
<option value="Waimea">Waimea-Kekaha</option>
<option value="Haena">Haena-Wainiha</option>
</select></td></tr>
<tr><td>Location:</td>
<td><input size="10" name="Location" ></td></tr>
<tr><td>Project Type:</td>
<td><input size="15" name="Proj_Type" ></td></tr>
<tr><td>Project Manager:</td>
<td><input size="50" name="Proj_Mgr" ></td></tr>
<tr><td>Percent Complete:</td>
<td><input size="3" name="Pct_Complete" ></td></tr>
<tr><td>Estimated Cost:</td>
<td><input size="50" name="Est_Cost"></td></tr>
<tr><td><input type="submit" value="Submit Record"></td></tr>
</table>
</form>
<% Else %>
<%
Dim Query, Connect, Classifieds, Place
ShowHeader "Enter New Project"
On Error Resume Next
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "ProjectInfo"
Set Classifieds = Server.CreateObject("ADODB.Recordset")
Classifieds.Open "Proj_Info",Connect,adOpenDynamic,adLockOptimistic,adCmdTa
ble
Classifieds.AddNew
Classifieds("ProjectNbr") = Request("ProjNbr")
Classifieds("ProjectName") = Request("ProjectName")
Classifieds("Description") = Request("Description")
Classifieds("WaterSystem") = Request("WaterSystem")
Classifieds("Location") = Request("Location")
Classifieds("ProjType") = Request("Proj_Type")
Classifieds("ProjMgr") = Request("Proj_Mgr")
Classifieds("PctComplete") = Request("Pct_Complete")
Classifieds("EstCost") = Request("Est_Cost")
Classifieds.Update
'Classifieds.Close
If Err.Number <> 0 Then %>
There was an error placing your ad.<p>
Error #<%=Err.Number%> : <%=Err.Description%><p>
<% End If %>
<% End If %></p>
</body>
</html>
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 26 Nov 2002 11:01:10 +1100
|
|
Do something like this:
<%@ Language=VBScript %>
<%
Option Explicit
If isPostBack() then
' Get Form Values
' And insert into database
End If
%>
<html>
<body>
<form method="post"
</form>
</body>
</html>
The form is posted back to itself. The isPostBack() routine works out
whether the form has been posted back (or just loaded the first time). If it
has been posted back you put the data into the database. The <html> part is
loaded no matter what. Optionally, you might want to include a simple text
message informing the user if their record was inserted without any errors.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: <jmendez@k...>
To: "Access ASP" <access_asp@p...>
Sent: Monday, November 25, 2002 6:08 PM
Subject: [access_asp] Submit Records without leaving Form Page
: I have an asp code that I am trying to build on from a sample that I read
: in a book. I am trying to enter table data, submit a record to a table,
: clear the form, and then be ready to enter data for next record.
: Continuous data entry without leaving the screen. I hope that somebody
: can help me out.
:
: Thank You. Below is my code.
:
: <% Option Explicit %>
: <!-- #include virtual="common/adovbs.inc" -->
: <html>
: <head>
: <title>Enter New Project Information</title>
: </head>
: <body bgcolor="#ffffff" vlink=black>
: <!-- #include file="header.inc" --><p>
:
: <%
: If Request("ProjNbr")="" Or Request("Description")="" Or _
: Request("ProjectName")="" Or Request("WaterSystem")="" Or _
: Request("Location")="" Or Request("Proj_Mgr")="" Then
: %>
: <% ShowHeader "Enter New Project" %>
: Please fill in all of these fields below. <p>
: When you are finished, click the Submit Record button.<p>
:
:
: <form method="post" action="placead.asp" name="ProjAdd" >
: <table>
: <tr><td>Project Number:</td>
: <td><input size="50" name="ProjNbr" ></td></tr>
:
: <TR><td valign=top>Project Name:</td>
: <td><input size=50 name="ProjectName" ></td></TR>
:
: <TR><td valign=top>Description:</td>
: <td><TEXTAREA cols=50 name="Description" rows=6></TEXTAREA></td></TR>
:
: <tr><td>Water System:</td>
: <td> <select name="WaterSystem" size="1">
: <option selected value="Lihue">Lihue-Hanamaulu</option>
: <option value="Kapaa">Wailua-Kapaa</option>
: <option value="Koloa">Koloa-Poipu</option>
: <option value="Waimea">Waimea-Kekaha</option>
: <option value="Haena">Haena-Wainiha</option>
: </select></td></tr>
:
: <tr><td>Location:</td>
: <td><input size="10" name="Location" ></td></tr>
:
: <tr><td>Project Type:</td>
: <td><input size="15" name="Proj_Type" ></td></tr>
:
: <tr><td>Project Manager:</td>
: <td><input size="50" name="Proj_Mgr" ></td></tr>
:
: <tr><td>Percent Complete:</td>
: <td><input size="3" name="Pct_Complete" ></td></tr>
:
: <tr><td>Estimated Cost:</td>
: <td><input size="50" name="Est_Cost"></td></tr>
:
: <tr><td><input type="submit" value="Submit Record"></td></tr>
: </table>
: </form>
:
: <% Else %>
: <%
: Dim Query, Connect, Classifieds, Place
:
: ShowHeader "Enter New Project"
:
: On Error Resume Next
:
: Set Connect = Server.CreateObject("ADODB.Connection")
: Connect.Open "ProjectInfo"
:
: Set Classifieds = Server.CreateObject("ADODB.Recordset")
: Classifieds.Open
"Proj_Info",Connect,adOpenDynamic,adLockOptimistic,adCmdTa
: ble
:
: Classifieds.AddNew
: Classifieds("ProjectNbr") = Request("ProjNbr")
: Classifieds("ProjectName") = Request("ProjectName")
: Classifieds("Description") = Request("Description")
: Classifieds("WaterSystem") = Request("WaterSystem")
: Classifieds("Location") = Request("Location")
: Classifieds("ProjType") = Request("Proj_Type")
: Classifieds("ProjMgr") = Request("Proj_Mgr")
: Classifieds("PctComplete") = Request("Pct_Complete")
: Classifieds("EstCost") = Request("Est_Cost")
: Classifieds.Update
: 'Classifieds.Close
:
: If Err.Number <> 0 Then %>
: There was an error placing your ad.<p>
: Error #<%=Err.Number%> : <%=Err.Description%><p>
: <% End If %>
: <% End If %></p>
:
:
: </body>
: </html>
|
|
 |