By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Need help with query for my code...

P: 2
The following form code is used to enter data into MSAccess database.

Expand|Select|Wrap|Line Numbers
  1. <div id="container" align="center">
  2.   <form action="First_Entry.asp" method="POST" name="form1">
  3.    <table border="0" width="100%" cellspacing="0" cellpadding="0">
  4.     <tr>
  5.      <td colspan="2" align="center"><img src="images/Abstract_Header5.gif" alt="Abstract Logo" border="0"></td>
  6.     </tr>
  7.     <tr>
  8.      <td colspan="2" align="center" class="text14BLB">New Subdivision Entry Form</td>
  9.     </tr>
  10.     <tr>
  11.      <td colspan="2" align="center" class="text12RS">* mark fields that are mandatory</td>
  12.     </tr>
  13.     <tr>
  14.      <td colspan="2">&nbsp;</td>
  15.     </tr>
  16.     <tr>
  17.      <td width="50%" align="right" class="text12BLB" style="padding-right: 10px"><span class="text12RB">*</span>Enter Subdivision Name:</td>
  18.      <td width="50%" align="left"><input type="text" name="SubName" onBlur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);"></td>
  19.     </tr>
  20.     <tr>
  21.      <td style="border-top:dashed 1px #ccc" colspan="2">&nbsp;</td>
  22.     </tr>
  23.     <tr>
  24.      <td width="50%" align="right" class="text12BLB" style="padding-right: 10px"><span class="text12RB">*</span>Document Type:</td>
  25.      <td width="50%" align="left"><input type="text" name="DocType" onBlur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);"></td>
  26.     </tr>
  27.     <tr>
  28.      <td style="border-top:dashed 1px #ccc" colspan="2">&nbsp;</td>
  29.     </tr>
  30.     <tr>
  31.      <td width="50%" align="right" class="text12BLB" style="padding-right: 10px"><span class="text12RB">*</span>Reception Number:</td>
  32.      <td width="50%" align="left"><input type="text" name="Reception" size="8" maxlength="8"></td>
  33.     </tr>
  34.     <tr>
  35.      <td style="border-top:dashed 1px #ccc" colspan="2">&nbsp;</td>
  36.     </tr>
  37.     <tr>
  38.      <td width="50%" align="right" class="text12BLB" style="padding-right: 10px"><span class="text12RB">*</span>Link to Document:</td>
  39.      <td width="50%" align="left"><input type="text" name="LinkTo" value=""></td>
  40.     </tr>
  41.  
  42.     <tr>
  43.      <td style="border-top:dashed 1px #ccc" colspan="2">&nbsp;</td>
  44.     </tr>
  45.  
  46.     <tr>
  47.      <td colspan="2">&nbsp;</td>
  48.     </tr>
  49.     <tr>
  50.      <td align="center" colspan="2"><input type="submit" value="Submit">&nbsp;&nbsp;<input type="reset" value="Reset"></td>
  51.     </tr>
  52.     <tr>
  53.      <td colspan="2">&nbsp;</td>
  54.     </tr>
  55.     <tr>
  56.      <td colspan="2">&nbsp;</td>
  57.     </tr>
  58.     <tr>
  59.      <td colspan="2" align="center"><span class="text12BLN">Having problems?&nbsp;</span><a href="ContactForm/contactus.html" title="Contact Form"><span class="text12BLB">Contact Us</span></a></td>
  60.     </tr>
  61.     <tr>
  62.      <td colspan="2">&nbsp;</td>
  63.     </tr>
  64.     <tr>
  65.      <td colspan="2" align="center"><a href="http://www.abstracttitle.biz" title="Return to Home Page"><span class="text12RS">Return to Home</span></a></td>
  66.     </tr>
  67.    </table>
  68.   </form>
  69. </div>
============================
The form action file 'First_Entry.asp' below is the code I am using to connect to db1.mdb and it works, however, I would like to know how to modify to do a Query search for 'SubName', which is the Subdivision name. Each subdivision has multiple 'DocType' associated with it. I would like to be able to view ALL of the 'DocType' associated with each 'SubName'. Is this possible? Thanks in advance!

Expand|Select|Wrap|Line Numbers
  1. <%
  2. if Request.ServerVariables("REQUEST_METHOD") = "POST" then
  3.  
  4.         strSubName = Request.Form("SubName")
  5.         strDocType = Request.Form("DocType")
  6.         strReception = Request.Form("Reception")
  7.         strLinkTo = Request.Form("LinkTo")
  8.  
  9.     strDate = Now()
  10.     blnValid = True
  11.     strValid = "<p align=""left""><font face=""Verdana"" size=""4"" color=""#FF00000""><b>" & _
  12.                "Entry Failed..!!</b></font></p>" & vbCrLf & _
  13.                "<ul><font face=""Verdana"" size=""2"" color=""#000080"">" & vbCrLf
  14.  
  15.     if strSubName = "" then
  16.         blnValid = False
  17.         strValid = strValid & "<table border=""0"" width=""302"" cellspacing=""0"" cellpadding=""0"" height=""22"">"  & vbCrLf &_
  18.              "<tr>"  & vbCrLf &_
  19.              "<td width=""300"" height=""22""><p align=""left""><font face=""Verdana"" size=""2"" color=""#000080""># Please Enter Subdivision Name.</p></td>"  & vbCrLf &_
  20.              "</tr>" & vbCrLf &_
  21.              "</table>" 
  22.    end if 
  23.  
  24.     if strDocType = "" then
  25.         blnValid = False
  26.         strValid = strValid & "<table border=""0"" width=""302"" cellspacing=""0"" cellpadding=""0"" height=""22"">"  & vbCrLf &_
  27.              "<tr>"  & vbCrLf &_
  28.              "<td width=""300"" height=""22""><p align=""left""><font face=""Verdana"" size=""2"" color=""#000080""># Please Enter Document Type.</p></td>"  & vbCrLf &_
  29.              "</tr>" & vbCrLf &_
  30.              "</table>" 
  31.    end if 
  32.  
  33.     if strReception = "" then
  34.         blnValid = False
  35.         strValid = strValid & "<table border=""0"" width=""302"" cellspacing=""0"" cellpadding=""0"" height=""22"">"  & vbCrLf &_
  36.              "<tr>"  & vbCrLf &_
  37.              "<td width=""300"" height=""22""><p align=""left""><font face=""Verdana"" size=""2"" color=""#000080""># Please Enter Reception Number.</p></td>"  & vbCrLf &_
  38.              "</tr>" & vbCrLf &_
  39.              "</table>"
  40.    end if 
  41.  
  42.     if strLinkTo = "" then
  43.         blnValid = False
  44.         strValid = strValid & "<table border=""0"" width=""302"" cellspacing=""0"" cellpadding=""0"" height=""22"">"  & vbCrLf &_
  45.              "<tr>"  & vbCrLf &_
  46.              "<td width=""300"" height=""22""><p align=""left""><font face=""Verdana"" size=""2"" color=""#000080""># Please Enter Link to Document.</p></td>"  & vbCrLf &_
  47.              "</tr>" & vbCrLf &_
  48.              "</table>"
  49.    end if 
  50.             strValid =  strValid & "<p align=""center""><a href=""CovData.asp"" target=""_top"" title=""Click Here""><font face=""Verdana"" size=""2"" color=""#0000FF"">Click Here To Continue</font></a></p>"
  51. else
  52.     strValid =  strValid & Response.Redirect ("CovData.asp")
  53.    end if  
  54.  
  55.     if blnValid = True then
  56.  
  57.         strDSNPath = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\db1.mdb")
  58.         strSQL_Insert = "INSERT INTO SubTbl (SubName, DocType, Reception, LinkTo)" & _
  59.                         " VALUES ('" & strSubName & "','" & strDocType & "','" & strReception & "','" & strLinkTo & "');"
  60.  
  61.        Set Conn=Server.CreateObject("ADODB.Connection")
  62.             Conn.Open strDSNPath
  63.                 On error resume next
  64.                 Conn.Execute strSQL_Insert
  65.             Conn.Close
  66.         Set Conn = Nothing   
  67.  
  68.     if err.number <> 0 then
  69.  
  70.             strValid = "<p align=center><font face=""Verdana"" size=""2"" color=""#F0000""><b>" & _
  71.                        "Sorry!</font></b><font face=""Verdana"" size=""2"" color=""#000080""> This Subdivision has been filled by someone else.</font><br>" & _
  72.                        "<br><font face=""Verdana"" size=""2"" color=""#000080"">Please choose a different <b>E-Mail Address</b> and <b>Username.</b></br>" & _
  73.                        "</font></p>" & _
  74.                        "<br><p align=""center""><a href=""CovData.asp"" target=""_self"" title=""Click Here""><font face=""Verdana"" size=""2"" color=""#0000FF"">Click Here To Continue</font></a></p>"
  75.         else
  76.  
  77.         strValid = "<p align=""left""><b><font face=""Verdana"" size=""2"" color=""#008080"">Dear " & strSubName & " " & strDocType & ".</b></font>" & _
  78.     "<p align=""center""><font face=""Verdana"" size=""2"" color=""#000080"">Your Name Has Been Registerd Successfully.</font></p><br>" & _
  79.                   "<center><table border=""0"" width=""327"" height=""39"" cellspacing=""0"" cellpadding=""0"">" &_
  80.     "<tr>" &_
  81.     "<td width=""98"" valign=""middle"" align=""center"" height=""21""><font size=""2"" face=""Verdana"" color=""#000080""><b>Username</b></font></td>" &_
  82.     "<td width=""20"" align=""left"" valign=""middle"" height=""21""><font size=""2"" face=""Verdana""><b>-</b></font></td>" &_
  83.     "<td width=""187"" valign=""middle"" align=""left"" height=""21""><font size=""2"" face=""Verdana"" color=""#FF0000"">" & strLinkTo & "</font></td>" &_
  84.     "</tr>" &_
  85.     "<tr>" &_
  86.     "<td width=""98"" valign=""middle"" align=""center"" height=""18""><font size=""2"" face=""Verdana"" color=""#000080""><b>Password</b></font></td>" &_
  87.     "<td width=""20"" align=""left"" valign=""middle"" height=""18""><font size=""2"" face=""Verdana""><b>-</b></font></td>" &_
  88.     "<td width=""187"" valign=""middle"" align=""left"" height=""18""><font size=""2"" face=""Verdana"" color=""#FF0000"">" & strPassword & "</font></td>" &_
  89.     "</tr></table></center>" &_
  90.     "<p align=""center""><a href=""site-admin/editSub.asp"" target=""_top"" title=""Click Here""><font face=""Verdana"" size=""2"" color=""#0000FF"">Click Here To Login</font></a></p>"
  91.  
  92. end if
  93. %>
Apr 20 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.