Solved

Upload File and Insert Record into Database  - 2 Actions with 1 Button

Posted on 2010-09-10
39
828 Views
Last Modified: 2012-05-10
I've seen similiar questions throughout the web but I'm still struggling with this one.

I have a form where a user supplies information and then can brows to for a file to upload if needed.

I'm using CS4 and ASP with access db (users choice).  I have successfully created the form which stores the path/filename in a text field in the database on the insert record server behavior.  However, i have not been successful at uploading the file to the server first.  I would like the user to only have to browse for the file once and have the submit button upload the file and insert the record if possible.

I have read and tried using Free ASP Upload.  I can get the upload to work fine.  But the upload and insert record are not working togther.  

Can someone help me get these two actions done with one Submit Button please?
0
Comment
Question by:FSAAdmin
  • 21
  • 17
39 Comments
 
LVL 10

Expert Comment

by:Kechka
ID: 33652391
Can you send your page code?
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33653517
I don't use Free ASP Upload, I used Persits ASPUpload, but the scripts should be similar.  The first page of code is the page that uploads an image to a directory and updates an existing record in an Access db.  The second page is the one that submits information.
<%
Set Upload = Server.CreateObject("Persits.Upload")

thePath = Session("FolderPath")
Upload.SetMaxSize 500000, True 'Limit image size
' Intercept all exceptions to display user-friendly error
On Error Resume Next 
Upload.Save(thePath)

' Error Check
loadStr = ""
' 8 is the number of "File too large" exception
If Err.Number = 8 Then
   Msgstr = "Your submitted file is too large, going back.."
   loadStr = "goBack();"
Else
   If Err <> 0 Then
      Msgstr = "An error occurred with your image, going back.."
	  loadStr = "goBack();"
   End If
End If

' Intercept all exceptions to display user-friendly error
On Error Resume Next

For Each File in Upload.Files
	If File.ImageType = "UNKNOWN" Then
		Msgstr = "This is not an image file, going back.."
		loadStr = "goBack();"
	End If
Next
Set conn = Server.CreateObject("ADODB.Connection")
'conn.ConnectionTimeout = 10
'conn.CommandTimeout = 10
'conn.Mode = 3
conn.open "DBQ=" & Server.MapPath("_database/Rides.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set rs = Server.CreateObject("ADODB.Recordset")

sql = "SELECT * FROM MyRide WHERE Username='" & Upload.Form("UserName") &"'" 
'Response.Write sql
rs.Open sql, conn, 3, 3

rs("FirstName") = Upload.Form("FirstName")
rs("LastName")  = Upload.Form("LastName")
rs("Make") = Upload.Form("Make")
rs("Model") = Upload.Form("Model")
rs("YearMade") = Upload.Form("YearMade")
rs("Email") = Upload.Form("Email")
rs("features") = Upload.Form("Features")

' Lets loop through and update the file name and description to the db

i = 1
For Each File in Upload.Files 
	rs("Description"&i&"") = Upload.Form("Description"&i&"")
	rs("ImageName"&i&"") = File.FileName 
	'Response.Write File.Size & " - " & File.Name & " - " & File.FileName & "<br>"
	i = i + 1 'Increment i
Next

'Post the form details and images to the users directory.
rs.Update 

On Error Resume Next
'Set Upload = Nothing
conn.Close
set rs = nothing
set conn = nothing
Session.Remove("folderPath")
'End If

%>
<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK rel="STYLESHEET" href="class/all.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" src="scripts/preload.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="scripts/HM_Loader.js" TYPE="text/javascript"></SCRIPT>
<script>
function goBack(){
setTimeout('history.go(-1)', 4000);
}
</script> 
<!--#include file="inc/include.asp"-->
</HEAD>
<BODY bgcolor="#FFFFFF" onLoad="<%=loadStr%>">
	<TABLE border="0" cellpadding="10" cellspacing="0" width="100%">
		<TR>
			<TD>	<!--#include file="inc/menu.asp"-->
	<TABLE cellspacing="10" cellpadding="10" border="0" width="80%" align="center">
		<TR>
			<TD>	
			</TD>
		</TR>
		<TR>
			<TD>	<% If loadStr > "" Then
							Response.Write msgStr
						Else
							Response.Write "Information loaded succesfully!<p> Click <a href=""myView.asp?uname="&Upload.Form("UserName")&">here </a> to view your ride."
						End If 'Call BuildMyRide("varSignin", Upload.Form("UserName"))%>
			</TD>
		</TR>
	</TABLE>
</BODY>
</HTML>
----------------------------------------------------------
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<LINK rel="STYLESHEET" href="class/all.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" src="scripts/preload.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="scripts/HM_Loader.js" TYPE="text/javascript"></SCRIPT>

</HEAD>
<BODY bgcolor="#FFFFFF">
<!--#include file="inc/menu.asp"-->
	<TABLE cellspacing="10" cellpadding="10" border="0" align="center">
		<TR>
			<TD>	Submit your vehicle to our website, we would love to hear from you about your ride!&nbsp;&nbsp;&nbsp;<FONT color="red">*</FONT> Required
<P>
				<TABLE border="0" cellpadding="4" cellspacing="0" width="650" align="center">
					<TR>
						<TD>
							<FORM action="submit_ride_test.asp" method="post" ENCTYPE="multipart/form-data"  name="ride1" id="ride1">
								<TR>
									<TD>	First Name: <FONT color="red">*</FONT>
									</TD>
									<TD>										
										<INPUT type="text" name="FirstName">
									</TD>
									<TD width="78">	Last Name: <FONT color="red">*</FONT>
									</TD>
									<TD>										
										<INPUT type="text" name="LastName">
									</TD>
								</TR>
								<TR>
									<TD>	Make: <FONT color="red">*</FONT>
									</TD>
									<TD>										
										<INPUT type="text" name="Make">
									</TD>
									<TD>	Model: <FONT color="red">*</FONT>
									</TD>
									<TD>										
										<INPUT type="text" name="Model">
									</TD>
								</TR>
								<TR>
									<TD width="205" valign="top">	Vehicle Features: <FONT color="red">*</FONT><BR>
									</TD>
									<TD colspan="3">
										<TEXTAREA cols="82" rows="6" name="features" id="features" onClick="document.ride1.features.value='';" class="TextField">Enter such things as engine, trans, mods, paint and body, interior...&nbsp;&nbsp;Anything you want to share about your ride.  

[click to clear]</TEXTAREA>
									</TD>
								</TR>
								<TR>
									<TD colspan="4">	You can upload as many as 3 images of your car, the images will be resized to 800x600 automatically and are limited to 500k in size.&nbsp;&nbsp;Accepted image types include .jpg, .gif and .bmp
									</TD>
						</TD>
					</TR>
					<TR>
						<TD>	Image 1:
						</TD>
						<TD>							
							<INPUT TYPE=FILE NAME="FILE1">
						</TD>
						<TD>	Description:
						</TD>
						<TD>							
							<INPUT TYPE=TEXT NAME="DESCR1">
						</TD>
					</TR>
					<TR>
						<TD>	Image 2:
						</TD>
						<TD>							
							<INPUT TYPE=FILE NAME="FILE2">
						</TD>
						<TD>	Description:
						</TD>
						<TD>							
							<INPUT TYPE=TEXT NAME="DESCR2">
						</TD>
					</TR>
					<TR>
						<TD>	Image 3:
						</TD>
						<TD>							
							<INPUT TYPE=FILE NAME="FILE3">
						</TD>
						<TD>	Description:
						</TD>
						<TD>							
							<INPUT TYPE=TEXT NAME="DESCR3">
						</TD>
					</TR>
					<TR>
						<TD>							
							<INPUT TYPE=SUBMIT VALUE="Upload!">
						</TD>
					</TR>
				</TABLE>
</FORM>
			</TD>
		</TR>
	</TABLE>
</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:FSAAdmin
ID: 33676585
Mgfranz -

Thanks for taking time to reply.  However I get an error message when trying to follow you sample.  

Set Upload = Server.CreateObject("Persits.Upload")
_____________________________________________________
Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed
0
 

Author Comment

by:FSAAdmin
ID: 33676603
Kecha -

I'm not sure where to ever start.  

As I stated, the Insert and upload work fine indepenet of each other.  But when I try to make them play together they hate it.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33676830
With my code you have to download and install Persits ASPUpload, http://www.aspupload.com/download.html  Check with your hosting server to see what Upload components they have installed since it's possible that they may or may not have this component installed.
0
 

Author Comment

by:FSAAdmin
ID: 33679101
Unfortunately I've been trying to find a "free" solution.  Do you have any other suggestions?
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 500 total points
ID: 33679146
Are you trying to use the file at http://www.freeaspupload.net/ ?  If so, you can still use most of my code with a simple modification to the "Free ASP Upload" file instead of the component.  The rest of the code is just database updates.  Remember, all you are doing is passing a set of form object data to the upload page, one part will upload the file to a directory and another part will update a db.  Think simple, do one thing at a time.

And post the .asp page you are working with.
0
 

Author Comment

by:FSAAdmin
ID: 33684059
This is the asp page that I am using to insert the record into the database.  The field that I wanted to attach the upload to is "Attachment".  

I will try to remove the insert record behavior and have the submission go to the second page.  However, this second page would be similiar to your first page correct?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

	<head>

		<title>My Test Upload</title>

		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

	



		<meta name="robots" content="all" />

		<meta name="MSSmartTagsPreventParsing" content="true" />

		

		

		<link rel="Shortcut Icon" type="image/x-icon" href="http://www.nmsu.edu/style/favicon.ico" />

		<link rel="stylesheet" href="http://www.nmsu.edu/style/unit_level.css" type="text/css" media="screen, tv" />

		<link rel="stylesheet" href="http://www.nmsu.edu/style/unit_level_print.css" type="text/css" media="print, projection" />

		<link rel="stylesheet" href="http://www.nmsu.edu/style/unit_level_other.css" type="text/css" media="aural, braille, embossed, handheld, tty" />

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<!--#include file="Connections/CONN_FCP.asp" -->

<%

Dim MM_editAction

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))

If (Request.QueryString <> "") Then

  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)

End If



' boolean to abort record edit

Dim MM_abortEdit

MM_abortEdit = false

%>

<%

' IIf implementation

Function MM_IIf(condition, ifTrue, ifFalse)

  If condition = "" Then

    MM_IIf = ifFalse

  Else

    MM_IIf = ifTrue

  End If

End Function

%>

<%

If (CStr(Request("MM_insert")) = "form2") Then

  If (Not MM_abortEdit) Then

    ' execute the insert

    Dim MM_editCmd



    Set MM_editCmd = Server.CreateObject ("ADODB.Command")

    MM_editCmd.ActiveConnection = MM_CONN_FCP_STRING

    MM_editCmd.CommandText = "INSERT INTO NotedIssues (Facility, Shop, Location, [Level], FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 

    MM_editCmd.Prepared = true

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Facility")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Shop2")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Location")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("Level")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Facility_Component")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("Employee_Adding_Issue")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Type_of_Equipment")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 50, Request.Form("Issue")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 50, Request.Form("Required_Correction")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Additional_Information")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Attachment")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 5, 1, -1, MM_IIF(Request.Form("Index_Number"), Request.Form("Index_Number"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 5, 1, -1, MM_IIF(Request.Form("AIM_WO"), Request.Form("AIM_WO"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 5, 1, -1, MM_IIF(Request.Form("Funding_Approved"), 1, 0)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202, 1, 255, Request.Form("Correction_Priority")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 135, 1, -1, MM_IIF(Request.Form("Correction_Estimated_Start"), Request.Form("Correction_Estimated_Start"), null)) ' adDBTimeStamp

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 5, 1, -1, MM_IIF(Request.Form("Estimate_Correction_Cost"), Request.Form("Estimate_Correction_Cost"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 135, 1, -1, MM_IIF(Request.Form("Correction_Estimated_Complete"), Request.Form("Correction_Estimated_Complete"), null)) ' adDBTimeStamp

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 202, 1, 255, Request.Form("Funding2")) ' adVarWChar

    MM_editCmd.Execute

    MM_editCmd.ActiveConnection.Close



    ' append the query string to the redirect URL

    Dim MM_editRedirectUrl

    MM_editRedirectUrl = "ThankYou.html"

    If (Request.QueryString <> "") Then

      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then

        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString

      Else

        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString

      End If

    End If

    Response.Redirect(MM_editRedirectUrl)

  End If

End If

%>

<%

Dim NotedIssues

Dim NotedIssues_cmd

Dim NotedIssues_numRows



Set NotedIssues_cmd = Server.CreateObject ("ADODB.Command")

NotedIssues_cmd.ActiveConnection = MM_CONN_FCP_STRING

NotedIssues_cmd.CommandText = "SELECT * FROM NotedIssues" 

NotedIssues_cmd.Prepared = true



Set NotedIssues = NotedIssues_cmd.Execute

NotedIssues_numRows = 0

%>

<%

Dim Facilities

Dim Facilities_cmd

Dim Facilities_numRows



Set Facilities_cmd = Server.CreateObject ("ADODB.Command")

Facilities_cmd.ActiveConnection = MM_CONN_FCP_STRING

Facilities_cmd.CommandText = "SELECT ID, BuildingName FROM Facilities" 

Facilities_cmd.Prepared = true



Set Facilities = Facilities_cmd.Execute

Facilities_numRows = 0

%>

<%

Dim Employee

Dim Employee_cmd

Dim Employee_numRows



Set Employee_cmd = Server.CreateObject ("ADODB.Command")

Employee_cmd.ActiveConnection = MM_CONN_FCP_STRING

Employee_cmd.CommandText = "SELECT * FROM FacilityReporter" 

Employee_cmd.Prepared = true



Set Employee = Employee_cmd.Execute

Employee_numRows = 0

%>

<%

Dim Funding

Dim Funding_cmd

Dim Funding_numRows



Set Funding_cmd = Server.CreateObject ("ADODB.Command")

Funding_cmd.ActiveConnection = MM_CONN_FCP_STRING

Funding_cmd.CommandText = "SELECT ID, Funding FROM Funding" 

Funding_cmd.Prepared = true



Set Funding = Funding_cmd.Execute

Funding_numRows = 0

%>

<%

Dim Priority

Dim Priority_cmd

Dim Priority_numRows



Set Priority_cmd = Server.CreateObject ("ADODB.Command")

Priority_cmd.ActiveConnection = MM_CONN_FCP_STRING

Priority_cmd.CommandText = "SELECT * FROM Priority" 

Priority_cmd.Prepared = true



Set Priority = Priority_cmd.Execute

Priority_numRows = 0

%>

<%

Dim Shop

Dim Shop_cmd

Dim Shop_numRows



Set Shop_cmd = Server.CreateObject ("ADODB.Command")

Shop_cmd.ActiveConnection = MM_CONN_FCP_STRING

Shop_cmd.CommandText = "SELECT * FROM Shop" 

Shop_cmd.Prepared = true



Set Shop = Shop_cmd.Execute

Shop_numRows = 0

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>



<body>

<div id="nmsu-web-document">

  <div id="full-document-container">

    <!-- HEADER -->

    <div id="header-container">

      <div id="header-contents">

        <div id="header-text">Office of Facilities  and Services</div>

        <div id="header-utility"><span></span></div>

      </div>

      <!-- header-contents -->

    </div>

    <!-- header-container -->

    <!-- END HEADER -->

    

		<!-- NAVIGATION --> 

			<div id="navigation-container"> 

				<div id="navigation-contents">

                

              

                <!--#include file="includes/condition_nav.html" -->

            </div> <!-- navigation-container --> 

    </div> <!-- navigation-container --> 

            <!-- END NAVIGATION -->

            

    <!-- MAIN DOCUMENT -->

    <div id="main-document-body-container">

      <div id="main-document-body-contents">

        <!-- TITLE BLOCK -->

        <div id="title-block">

          <div id="unit-title">OFS Facility Condition Tracking</div>

        </div>

        <!-- END TITLE BLOCK -->

        <!-- BREADCRUMB TRAIL -->

        <div id="breadcrumb-trail-container">

          <div id="breadcrumb-trail-contents">

            <div id="breadcrumb-you-are-here"></div>

            <div id="breadcrumb-link-list"> </div>

            <!-- breadcrumb-link-list -->

            <div id="breadcrumb-utility"><span></span></div>

          </div>

          <!-- breadcrumb-trail-contents -->

        </div>

        <!-- breadcrumb-trail-container -->

        <!-- END BREADCRUMB TRAIL -->

        <!-- PRIMARY CONTENT BLOCK -->

        <div id="primary-content-container">

          <h1>Insert Condition</h1>





                    <form action="<%=MM_editAction%>" method="POST" name="form2" id="form2">



         



            <table>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Facility:</td>

                <td><select name="Facility">

                  <%

While (NOT Facilities.EOF)

%>

                  <%

  Facilities.MoveNext()

Wend

If (Facilities.CursorType > 0) Then

  Facilities.MoveFirst

Else

  Facilities.Requery

End If

%>

                  <%

While (NOT Facilities.EOF)

%>

<option value="<%=(Facilities.Fields.Item("BuildingName").Value)%>" <%If (Not isNull((NotedIssues.Fields.Item("Facility").Value))) Then If (CStr(Facilities.Fields.Item("BuildingName").Value) = CStr((NotedIssues.Fields.Item("Facility").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Facilities.Fields.Item("BuildingName").Value)%></option>

                  <%

  Facilities.MoveNext()

Wend

If (Facilities.CursorType > 0) Then

  Facilities.MoveFirst

Else

  Facilities.Requery

End If

%>

                </select></td>

                <td align="right">Shop:</td>

                <td><select name="Shop2">

                  <%

While (NOT Shop.EOF)

%>

                  <option value="<%=(Shop.Fields.Item("Shop").Value)%>"><%=(Shop.Fields.Item("Shop").Value)%></option>

                  <%

  Shop.MoveNext()

Wend

If (Shop.CursorType > 0) Then

  Shop.MoveFirst

Else

  Shop.Requery

End If

%>

                </select></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Location:</td>

                <td><input type="text" name="Location" value="" size="32" /></td>

                <td align="right">Level:</td>

                <td><input type="text" name="Level" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Facility Component:</td>

                <td><input type="text" name="Facility_Component" value="" size="32" /></td>

                <td align="right">Employee:</td>

                <td><select name="Employee_Adding_Issue">

                  <%

While (NOT Employee.EOF)

%>

                  <option value="<%=(Employee.Fields.Item("Name").Value)%>"><%=(Employee.Fields.Item("Name").Value)%></option>

                  <%

  Employee.MoveNext()

Wend

If (Employee.CursorType > 0) Then

  Employee.MoveFirst

Else

  Employee.Requery

End If

%>

                </select></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Equipment Type:</td>

                <td colspan="3"><textarea name="Type_of_Equipment" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Issue:</td>

                <td colspan="3"><textarea name="Issue" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Required Correction:</td>

                <td colspan="3"><textarea name="Required_Correction" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Additional Information:</td>

                <td colspan="3"><textarea name="Additional_Information" cols="60" rows="3"></textarea></td>

              </tr>

          <tr valign="baseline">

                <td nowrap="nowrap" align="right">Attachment:</td>

			<td><input type="file" name="Attachment" value="" size="32"  /></td>

            <td></td>

                       

                                

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Index Number:</td>

                <td><input type="text" name="Index_Number" value="" size="32" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

          </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">AIM WO:</td>

                <td><input type="text" name="AIM_WO" value="" size="32" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Funding Approved:</td>

                <td><input type="checkbox" name="Funding_Approved" value="1" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Priority:</td>

                <td><select name="Correction_Priority">

                  <%

While (NOT Priority.EOF)

%>

                  <%

  Priority.MoveNext()

Wend

If (Priority.CursorType > 0) Then

  Priority.MoveFirst

Else

  Priority.Requery

End If

%>

                  <%

While (NOT Priority.EOF)

%>

<option value="<%=(Priority.Fields.Item("Description").Value)%>" <%If (Not isNull((NotedIssues.Fields.Item("CorrectionPriority").Value))) Then If (CStr(Priority.Fields.Item("Description").Value) = CStr((NotedIssues.Fields.Item("CorrectionPriority").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Priority.Fields.Item("Description").Value)%></option>

                  <%

  Priority.MoveNext()

Wend

If (Priority.CursorType > 0) Then

  Priority.MoveFirst

Else

  Priority.Requery

End If

%>

                </select></td>

                <td align="right">Start Date:</td>

                <td><input type="text" name="Correction_Estimated_Start" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Cost:</td>

                <td><input type="text" name="Estimate_Correction_Cost" value="" size="32" /></td>

                <td align="right">Complete Date:</td>

                <td><input type="text" name="Correction_Estimated_Complete" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Funding:</td>

                <td><select name="Funding2">

                  <%

While (NOT Funding.EOF)

%>

                  <option value="<%=(Funding.Fields.Item("Funding").Value)%>"><%=(Funding.Fields.Item("Funding").Value)%></option>

                  <%

  Funding.MoveNext()

Wend

If (Funding.CursorType > 0) Then

  Funding.MoveFirst

Else

  Funding.Requery

End If

%>

                </select></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">&nbsp;</td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">&nbsp;</td>

                <td align="right"><input type="submit" value="Insert record" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

            </table>

            <input type="hidden" name="MM_insert" value="form2" />

          </form>

         

        </div>

      </div>

    </div>

  </div>

  <div id="footer-container">

    <!-- footer-contents -->

  </div>

  <!-- footer-container -->

  <!-- END FOOTER -->

</div>



</body>

</html>

<%

NotedIssues.Close()

Set NotedIssues = Nothing

%>

<%

Facilities.Close()

Set Facilities = Nothing

%>

<%

Employee.Close()

Set Employee = Nothing

%>

<%

Funding.Close()

Set Funding = Nothing

%>

<%

Priority.Close()

Set Priority = Nothing

%>

<%

Shop.Close()

Set Shop = Nothing

%>

Open in new window

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33684389
Good God... DreamWeaver...
0
 

Author Comment

by:FSAAdmin
ID: 33684755
Yes I use Dreamweaver.  

Now on the submit of the page, I would then make a refernece to a new page which would have the behavior of the submit_ride_test.asp example you provided.

I would omit this piece of your code and use the piece from the Set Upload = Server.CreateObject("Persits.Upload") and submit to the free asp upload page?
0
 

Author Comment

by:FSAAdmin
ID: 33695486
I've tried to add the insert statement when the file is being saved but I get the error message that

I get the following error - however, this the correct spelling of the database and path.  I have given full persmissions to users on the folder and can write to the database fine elsewhere.

Microsoft JET Database Engine error '80004005'

Could not find file 'C:\Inetpub\wwwroot\FacilityConditionTracking\FacilitiesPlan.accdb'.

/FacilityConditionTracking/uploadTester4.asp, line 94
function SaveFiles

    Dim Upload, fileName, fileSize, ks, i, fileKey



    Set Upload = New FreeASPUpload

    Upload.Save(uploadsDirVar)



    ' If something fails inside the script, but the exception is handled

    If Err.Number<>0 then Exit function



    SaveFiles = ""

    ks = Upload.UploadedFiles.keys

    if (UBound(ks) <> -1) then

    response.write "<h3>Upload Success!</h3>"

        SaveFiles = "<B>You have successfully uploaded:</B> "

                

                Dim CurrentTime

                CurrentTime = NOW()

                Dim cn,sql,theFile,sFileTitle

                Set cn = Server.CreateObject("ADODB.Connection")

                cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("FacilitiesPlan.accdb") &";Persist Security Info=False"

                



        for each fileKey in Upload.UploadedFiles.keys

        

                SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " <br>"

               ' SaveFiles = SaveFiles & "<br>You can view this document here: "    

                'SaveFiles = SaveFiles & "http://www.mywebsite.co.uk/tempUploads/" & Upload.UploadedFiles(fileKey).FileName

        

                

                theFile = Upload.UploadedFiles(fileKey).FileName ' the filename of the actual file

                sFileTitle = Upload.Form(Upload.UploadedFiles(fileKey) & "_name") ' what the user entered in the filename field

    

                'insert query



				

                sql = "Insert into NotedIssues([attachment],[funding,file_name) values (" _

                & "'" & attach1 & "', " _

                & "'" & funding & ")"

  

                cn.Execute(sql)

        

        next

                    

                'Now that we have displayed the table data lets close the connection

                cn.Close

                Set cn = nothing

        

    else

        SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."

    end if

    'SaveFiles = SaveFiles & "<br>Enter a number = " & Upload.Form("enter_a_number") & "<br>"

    'SaveFiles = SaveFiles & "Checkbox values = " & Upload.Form("checkbox_values") & "<br>"

end function

Open in new window

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33695677
Well, first of all, that is not the entire code for the page in question since there is no line 94 in your code.  Second of all, in your code, you have the line;

"Server.MapPath("FacilitiesPlan.accdb")"

This translates the connection string to locate the database file in the root folder, basically it is looking for it in the path;

"http://www.yoursite.com/directory OfScript.asp/FacilitiesPlan.accdb"

Is that where you have the database?  In the same directory of the script?  You need to be specific when using Server.MapPath(), Read here for more, http://www.4guysfromrolla.com/webtech/121799-1.shtml
0
 

Author Comment

by:FSAAdmin
ID: 33696028
Yes for development purposes I placed everything in the root foolder.

The error on line 94 is line 20 above.
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("FacilitiesPlan.accdb") &";Persist Security Info=False"

Open in new window

0
 

Author Comment

by:FSAAdmin
ID: 33716952
I've created a new database folder and get the same error.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33717161
There are hundreds of reasons why you would be getting an '80004005' error, most of them have to do with permissions.  The file and the folder need to have IUSER permissions opened up.  This might help.  http://imar.spaanjaars.com/263/how-do-i-fix-asp-80004005-errors
0
 

Author Comment

by:FSAAdmin
ID: 33717786
OK, I've follolwed the instructions and receive a different error.

Microsoft JET Database Engine error '80040e4d'

Cannot start your application. The workgroup information file is missing or opened exclusively by another user.

/FacilityConditionTracking/uploadTester3.asp, line 101

MyConnection.Open MyConnectionString
Dim MyConnection

				Dim MyConnectionString

				Dim MySQLStatement

				

				MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &_

				"Data Source=C:\Inetpub\wwwroot\FacilityConditionTracking\Database; User ID=bftasks;Password=JumboDog"       

				MySQLStatement = "INSERT INTO NotedIssues (AiMWO) Values ('166777')"

				

				Set MyConnection = Server.CreateObject("ADODB.Connection")

				MyConnection.Open MyConnectionString

				MyConnection.Execute(MySQLStatement)

				MyConnection.Close()

				

				Response.Write ("Record inserted")

				Set MyConnection = Nothing

Open in new window

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33719475
It's not a good idea to post usernames and passwords to an open forum...

That aside, this is still a security issue, try this link for more.  http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_22996674.html
0
 

Author Comment

by:FSAAdmin
ID: 33719984
those were bogus id's and passwords.  Thanks for pointing that out.  

I converted the database to an Access 2003 database and I'm able to upload the file and insert a record.  

I'd like to keep it an Access 2007 database so i guess I'll need to research the connection string format.

Here's what I used for 2003 databse connection and it worked.
Dim MyConnection

				Dim MyConnectionString

				Dim MySQLStatement

				

				MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &_

				"Data Source=C:\Inetpub\wwwroot\FacilityConditionTracking\Database\FaciltiesPlan.mdb;" &_

				"User Id=;Password="       

		



Set MyConnection = Server.CreateObject("ADODB.Connection")

				MyConnection.Open MyConnectionString

				MyConnection.Execute(MySQLStatement)

				MyConnection.Close()

				

				Response.Write ("Record inserted")

				Set MyConnection = Nothing

Open in new window

0
 

Author Comment

by:FSAAdmin
ID: 33721115
Made some more progress.  I'm able to insert a record to the 2007 Access DB and upload the file at the same time.  I can only do this when I use literal values.  When I try to pull the data from the form fields, I get an error

Microsoft Office Access Database Engine error '80040e14'

Syntax error in INSERT INTO statement.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<% 

Response.Expires = -1

Server.ScriptTimeout = 600

' All communication must be in UTF-8, including the response back from the request

Session.CodePage  = 65001

%>

<!-- #include file="Connections/CONN_FCP.asp" -->

<!--#include file="freeaspupload.asp" -->

<%

Dim MM_editAction

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))

If (Request.QueryString <> "") Then

  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)

End If



' boolean to abort record edit

Dim MM_abortEdit

MM_abortEdit = false

%>

<%

' IIf implementation

Function MM_IIf(condition, ifTrue, ifFalse)

  If condition = "" Then

    MM_IIf = ifFalse

  Else

    MM_IIf = ifTrue

  End If

End Function

%>

<%

If (CStr(Request("MM_insert")) = "form2") Then

  If (Not MM_abortEdit) Then

    ' execute the insert

    Dim MM_editCmd



    Set MM_editCmd = Server.CreateObject ("ADODB.Command")

    MM_editCmd.ActiveConnection = MM_CONN_FCP_STRING

    MM_editCmd.CommandText = "INSERT INTO NotedIssues (Facility, Shop, Location, [Level], FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 

    MM_editCmd.Prepared = true

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Facility")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Shop2")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("Location")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("Level")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Facility_Component")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("Employee_Adding_Issue")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 255, Request.Form("Type_of_Equipment")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 50, Request.Form("Issue")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 50, Request.Form("Required_Correction")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("Additional_Information")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("Attachment")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 5, 1, -1, MM_IIF(Request.Form("Index_Number"), Request.Form("Index_Number"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 5, 1, -1, MM_IIF(Request.Form("AIM_WO"), Request.Form("AIM_WO"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 5, 1, -1, MM_IIF(Request.Form("Funding_Approved"), 1, 0)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202, 1, 255, Request.Form("Correction_Priority")) ' adVarWChar

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 135, 1, -1, MM_IIF(Request.Form("Correction_Estimated_Start"), Request.Form("Correction_Estimated_Start"), null)) ' adDBTimeStamp

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 5, 1, -1, MM_IIF(Request.Form("Estimate_Correction_Cost"), Request.Form("Estimate_Correction_Cost"), null)) ' adDouble

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 135, 1, -1, MM_IIF(Request.Form("Correction_Estimated_Complete"), Request.Form("Correction_Estimated_Complete"), null)) ' adDBTimeStamp

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 202, 1, 255, Request.Form("Funding2")) ' adVarWChar

    MM_editCmd.Execute

    MM_editCmd.ActiveConnection.Close



    ' append the query string to the redirect URL

    Dim MM_editRedirectUrl

    MM_editRedirectUrl = "bj4insert.asp"

    If (Request.QueryString <> "") Then

      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then

        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString

      Else

        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString

      End If

    End If

    Response.Redirect(MM_editRedirectUrl)

  End If

End If

%>

<%

Dim NotedIssues

Dim NotedIssues_cmd

Dim NotedIssues_numRows



Set NotedIssues_cmd = Server.CreateObject ("ADODB.Command")

NotedIssues_cmd.ActiveConnection = MM_CONN_FCP_STRING

NotedIssues_cmd.CommandText = "SELECT * FROM NotedIssues" 

NotedIssues_cmd.Prepared = true



Set NotedIssues = NotedIssues_cmd.Execute

NotedIssues_numRows = 0

%>

<%

Dim Facilities

Dim Facilities_cmd

Dim Facilities_numRows



Set Facilities_cmd = Server.CreateObject ("ADODB.Command")

Facilities_cmd.ActiveConnection = MM_CONN_FCP_STRING

Facilities_cmd.CommandText = "SELECT ID, BuildingName FROM Facilities" 

Facilities_cmd.Prepared = true



Set Facilities = Facilities_cmd.Execute

Facilities_numRows = 0

%>

<%

Dim Employee

Dim Employee_cmd

Dim Employee_numRows



Set Employee_cmd = Server.CreateObject ("ADODB.Command")

Employee_cmd.ActiveConnection = MM_CONN_FCP_STRING

Employee_cmd.CommandText = "SELECT * FROM FacilityReporter" 

Employee_cmd.Prepared = true



Set Employee = Employee_cmd.Execute

Employee_numRows = 0

%>

<%

Dim Funding

Dim Funding_cmd

Dim Funding_numRows



Set Funding_cmd = Server.CreateObject ("ADODB.Command")

Funding_cmd.ActiveConnection = MM_CONN_FCP_STRING

Funding_cmd.CommandText = "SELECT ID, Funding FROM Funding" 

Funding_cmd.Prepared = true



Set Funding = Funding_cmd.Execute

Funding_numRows = 0

%>

<%

Dim Priority

Dim Priority_cmd

Dim Priority_numRows



Set Priority_cmd = Server.CreateObject ("ADODB.Command")

Priority_cmd.ActiveConnection = MM_CONN_FCP_STRING

Priority_cmd.CommandText = "SELECT * FROM Priority" 

Priority_cmd.Prepared = true



Set Priority = Priority_cmd.Execute

Priority_numRows = 0

%>

<%

Dim Shop

Dim Shop_cmd

Dim Shop_numRows



Set Shop_cmd = Server.CreateObject ("ADODB.Command")

Shop_cmd.ActiveConnection = MM_CONN_FCP_STRING

Shop_cmd.CommandText = "SELECT * FROM Shop" 

Shop_cmd.Prepared = true



Set Shop = Shop_cmd.Execute

Shop_numRows = 0

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script>

function onSubmitForm() {

    var formDOMObj = document.form2;

    if (formDOMObj.attach1.value == "")

        alert("Please press the Browse button and pick a file.")

    else

        return true;

    return false;

}

</script>

<title>Untitled Document</title>

</head>



<body>

<div id="nmsu-web-document">

  <div id="full-document-container">

    <!-- HEADER -->

    <div id="header-container">

      <div id="header-contents">

        <div id="header-text">Office of Facilities  and Services</div>

        <div id="nmsu-logo"><a href="http://www.nmsu.edu/"><img src="http://www.nmsu.edu/images/logo2.gif" alt="NM State logo" width="59" height="66" /></a></div>

        <div id="header-utility"><span></span></div>

      </div>

      <!-- header-contents -->

    </div>

    <!-- header-container -->

    <!-- END HEADER -->

    

		<!-- NAVIGATION --> 

			<div id="navigation-container"> 

				<div id="navigation-contents">

                

              

                <!--#include file="includes/condition_nav.html" -->

            </div> <!-- navigation-container --> 

    </div> <!-- navigation-container --> 

            <!-- END NAVIGATION -->

            

    <!-- MAIN DOCUMENT -->

    <div id="main-document-body-container">

      <div id="main-document-body-contents">

        <!-- TITLE BLOCK -->

        <div id="title-block">

          <div id="unit-title">OFS Facility Condition Tracking</div>

        </div>

        <!-- END TITLE BLOCK -->

        <!-- BREADCRUMB TRAIL -->

        <div id="breadcrumb-trail-container">

          <div id="breadcrumb-trail-contents">

            <div id="breadcrumb-you-are-here"></div>

            <div id="breadcrumb-link-list"> </div>

            <!-- breadcrumb-link-list -->

            <div id="breadcrumb-utility"><span></span></div>

          </div>

          <!-- breadcrumb-trail-contents -->

        </div>

        <!-- breadcrumb-trail-container -->

        <!-- END BREADCRUMB TRAIL -->

        <!-- PRIMARY CONTENT BLOCK -->

        <div id="primary-content-container">

          <h1>Insert Condition</h1>

<%





  ' ****************************************************

  ' Change the value of the variable below to the pathname

  ' of a directory with write permissions, for example "C:\Inetpub\wwwroot"

  ' ****************************************************



  Dim uploadsDirVar

  uploadsDirVar = "c:\inetpub\wwwroot\FacilityConditionTracking\files" 

  



  ' Note: this file uploadTester.asp is just an example to demonstrate

  ' the capabilities of the freeASPUpload.asp class. There are no plans

  ' to add any new features to uploadTester.asp itself. Feel free to add

  ' your own code. If you are building a content management system, you

  ' may also want to consider this script: http://www.webfilebrowser.com/



function OutputForm()

%>

    <form name="form2" method="POST" enctype="multipart/form-data" accept-charset="utf-8" action="<%=MM_editAction%>" onSubmit="return onSubmitForm();">

         

       



            <table>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Facility:</td>

                <td><select name="Facility">

                  <%

While (NOT Facilities.EOF)

%>

                  <%

  Facilities.MoveNext()

Wend

If (Facilities.CursorType > 0) Then

  Facilities.MoveFirst

Else

  Facilities.Requery

End If

%>

                  <%

While (NOT Facilities.EOF)

%>

                  <option value="<%=(Facilities.Fields.Item("BuildingName").Value)%>" <%If (Not isNull((NotedIssues.Fields.Item("Facility").Value))) Then If (CStr(Facilities.Fields.Item("BuildingName").Value) = CStr((NotedIssues.Fields.Item("Facility").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Facilities.Fields.Item("BuildingName").Value)%></option>

                  <%

  Facilities.MoveNext()

Wend

If (Facilities.CursorType > 0) Then

  Facilities.MoveFirst

Else

  Facilities.Requery

End If

%>

                </select></td>

                <td align="right">Shop:</td>

                <td><select name="Shop2">

                  <%

While (NOT Shop.EOF)

%>

                  <option value="<%=(Shop.Fields.Item("Shop").Value)%>"><%=(Shop.Fields.Item("Shop").Value)%></option>

                  <%

  Shop.MoveNext()

Wend

If (Shop.CursorType > 0) Then

  Shop.MoveFirst

Else

  Shop.Requery

End If

%>

                </select></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Location:</td>

                <td><input type="text" name="Location" value="" size="32" /></td>

                <td align="right">Level:</td>

                <td><input type="text" name="Level" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Facility Component:</td>

                <td><input type="text" name="Facility_Component" value="" size="32" /></td>

                <td align="right">Employee:</td>

                <td><select name="Employee_Adding_Issue">

                  <%

While (NOT Employee.EOF)

%>

                  <option value="<%=(Employee.Fields.Item("Name").Value)%>"><%=(Employee.Fields.Item("Name").Value)%></option>

                  <%

  Employee.MoveNext()

Wend

If (Employee.CursorType > 0) Then

  Employee.MoveFirst

Else

  Employee.Requery

End If

%>

                </select></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Equipment Type:</td>

                <td colspan="3"><textarea name="Type_of_Equipment" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Issue:</td>

                <td colspan="3"><textarea name="Issue" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Required Correction:</td>

                <td colspan="3"><textarea name="Required_Correction" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td align="right" valign="middle" nowrap="nowrap">Additional Information:</td>

                <td colspan="3"><textarea name="Additional_Information" cols="60" rows="3"></textarea></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Attachment:</td>

                <td><input type="hidden" name="Attachment">

<input type="file" name="FileDialog" size="32" onChange="this.form.Attachment.value = this.value;"></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Index Number:</td>

                <td><input type="text" name="Index_Number" value="" size="32" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">AIM WO:</td>

                <td><input type="text" name="AIM_WO" value="" size="32" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Funding Approved:</td>

                <td><input type="checkbox" name="Funding_Approved" value="1" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Priority:</td>

                <td><select name="Correction_Priority">

                  <%

While (NOT Priority.EOF)

%>

                  <%

  Priority.MoveNext()

Wend

If (Priority.CursorType > 0) Then

  Priority.MoveFirst

Else

  Priority.Requery

End If

%>

                  <%

While (NOT Priority.EOF)

%>

<option value="<%=(Priority.Fields.Item("Description").Value)%>" <%If (Not isNull((NotedIssues.Fields.Item("CorrectionPriority").Value))) Then If (CStr(Priority.Fields.Item("Description").Value) = CStr((NotedIssues.Fields.Item("CorrectionPriority").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Priority.Fields.Item("Description").Value)%></option>

                  <%

  Priority.MoveNext()

Wend

If (Priority.CursorType > 0) Then

  Priority.MoveFirst

Else

  Priority.Requery

End If

%>

                </select></td>

                <td align="right">Start Date:</td>

                <td><input type="text" name="Correction_Estimated_Start" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Cost:</td>

                <td><input type="text" name="Estimate_Correction_Cost" value="" size="32" /></td>

                <td align="right">Complete Date:</td>

                <td><input type="text" name="Correction_Estimated_Complete" value="" size="23" /></td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">Funding:</td>

                <td><select name="Funding2">

                  <%

While (NOT Funding.EOF)

%>

                  <option value="<%=(Funding.Fields.Item("Funding").Value)%>"><%=(Funding.Fields.Item("Funding").Value)%></option>

                  <%

  Funding.MoveNext()

Wend

If (Funding.CursorType > 0) Then

  Funding.MoveFirst

Else

  Funding.Requery

End If

%>

                </select></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">&nbsp;</td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

              <tr valign="baseline">

                <td nowrap="nowrap" align="right">&nbsp;</td>

                <td align="right"><input type="submit" value="Insert record" /></td>

                <td>&nbsp;</td>

                <td>&nbsp;</td>

              </tr>

            </table>

            <input type="hidden" name="MM_insert" value="form2" />

          </form>

         <%

end function



function TestEnvironment()

    Dim fso, fileName, testFile, streamTest

    TestEnvironment = ""

    Set fso = Server.CreateObject("Scripting.FileSystemObject")

    if not fso.FolderExists(uploadsDirVar) then

        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."

        exit function

    end if

    fileName = uploadsDirVar & "\test.txt"

    on error resume next

    Set testFile = fso.CreateTextFile(fileName, true)

    If Err.Number<>0 then

        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."

        exit function

    end if

    Err.Clear

    testFile.Close

    fso.DeleteFile(fileName)

    If Err.Number<>0 then

        TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."

        exit function

    end if

    Err.Clear

    Set streamTest = Server.CreateObject("ADODB.Stream")

    If Err.Number<>0 then

        TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."

        exit function

    end if

    Set streamTest = Nothing

end function



function SaveFiles

    Dim Upload, fileName, fileSize, ks, i, fileKey



    Set Upload = New FreeASPUpload

    Upload.Save(uploadsDirVar)



	' If something fails inside the script, but the exception is handled

	If Err.Number<>0 then Exit function



    SaveFiles = ""

    ks = Upload.UploadedFiles.keys

    if (UBound(ks) <> -1) then

        SaveFiles = "<B>Files uploaded:</B> "

		

		Dim MyConnection

				Dim MyConnectionString

				Dim MySQLStatement

				

			'	MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &_

				MyConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" &_

				"Data Source=C:\Inetpub\wwwroot\FacilityConditionTracking\Database\FaciltiesPlan.accdb;" &_

				"User Id=Admin;Password="       



				

        for each fileKey in Upload.UploadedFiles.keys

            SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "

			'Begin Code to insert record here........

'			MySQLStatement = "INSERT INTO NotedIssues (AiMWO) Values ('777777')"



			'	MySQLStatement = "INSERT INTO NotedIssues (Facility, Shop, Location, [Level], FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ([FACILITY}, [shop2], [Location], [Level], [FacilityComponent], [EmployeeAddingIssue], [TypeofEquipment], [Issue], [RequiredCorrection], [AdditionalInformation], [Attachment], [IndexNumber], [AIMWO], [FundingApproved], [CorrectionPriority], [CorrectionEstimatedStart], [EstimateCorrectionCost], [CorrectionEstimateComplete], [Funding])" 

			'	MySQLStatement = "INSERT INTO NotedIssues (Facility, Shop, Location, [Level], FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ([FACILITY], [shop2], [Location], [Level], [Facility_Component], [Employee_Adding_Issue], [Type_of_Equipment], [Issue], [Required_Correction], [Additional_Information], [Attachment], [Index_Number], [AIM_WO], [Funding_Approved], [Correction_Priority], [Correction_Estimated_Start], [Estimate_Correction_Cost], [Correction_Estimate_Complete], [Funding2])" 

			

				MySQLStatement = "INSERT INTO NotedIssues (Facility, Shop, Location, Level, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES (@Facility, @Shop2, @Location, @Level, @FacilityComponent, @Employee_Adding_Issue, @Type_of_Equipment, @Issue, @Required_Correction, @Additional_Information, @Attachment, @Index_Number, @AIM_WO, @Funding_Approved, @Correction_Priority, @Correction_Estimated_Start, @Estiamte_Correction_Cost, @Correction_Estimated_Complete, @Funding2)" 

			

	Set MyConnection = Server.CreateObject("ADODB.Connection")

				MyConnection.Open MyConnectionString

				MyConnection.Execute(MySQLStatement)

				MyConnection.Close()

				

				Response.Write ("Record inserted")

				Set MyConnection = Nothing

        next

    else

        SaveFiles = "No file selected for upload or the file name specified in the upload form does not correspond to a valid file in the system."

    end if

end function

%>



        </div>

      </div>

    </div>

  </div>

  <div id="footer-container">

    <!-- footer-contents -->

  </div>

  <!-- footer-container -->

  <!-- END FOOTER -->

</div>

<%

Dim diagnostics

if Request.ServerVariables("REQUEST_METHOD") <> "POST" then

    diagnostics = TestEnvironment()

    if diagnostics<>"" then

        response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"

        response.write diagnostics

        response.write "<p>After you correct this problem, reload the page."

        response.write "</div>"

    else

        response.write "<div style=""margin-left:150"">"

        OutputForm()

        response.write "</div>"

    end if

else

    response.write "<div style=""margin-left:150"">"

    OutputForm()

    response.write SaveFiles()

    response.write "<br><br></div>"

end if



%>







</body>

</html>

<%

NotedIssues.Close()

Set NotedIssues = Nothing

%>

<%

Facilities.Close()

Set Facilities = Nothing

%>

<%

Employee.Close()

Set Employee = Nothing

%>

<%

Funding.Close()

Set Funding = Nothing

%>

<%

Priority.Close()

Set Priority = Nothing

%>

<%

Shop.Close()

Set Shop = Nothing

%>

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 18

Expert Comment

by:mgfranz
ID: 33721217
Do a Response.Write on the Insert string before running the Execute, chances are there is an issue with a parameter being a string and not a integer or something like that.

I have never used a connection string with the .accdb database, only .mdb or SQL databases so I can't help with why the 2007 database won't work, unless it wasn't properly configured somehow.
0
 

Author Comment

by:FSAAdmin
ID: 33726006
Here's what I get............

Astronomy BuildingAdministration008.jpgINSERT INTO NotedIssues (FACILITY, shop2, Location, Level, Facility_Component, Employee_Adding_Issue, Type_of_Equipment, Issue, Required_Correction, Additional_Information, Attachment, Index_Number, AIM_WO, Funding_Approved, Correction_Priority, Correction_Estimated_Start, Estimate_Correction_Cost, Correction_Estimate_Complete, Funding2) VALUES (Astronomy Building','Administration','','',' ',' Amezquita, Esther F.','','', '',' ','008.jpg','Astronomy Building','','','Service Affecting','','','Astronomy Building','BRR)

Microsoft Office Access Database Engine error '80040e14'

Syntax error in INSERT INTO statement.
0
 
LVL 18

Assisted Solution

by:mgfranz
mgfranz earned 500 total points
ID: 33726153
You can't use the word "LEVEL" in your field naming, it's a reserved word in Jet.

Might I suggest the use of a little web site called Google, you might have heard of them, it can be found at http://www.google.com  If you click on this link, http://www.google.com/search?q=80040e14+%22Syntax+error+in+INSERT+INTO+statement%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a  you will get a whole lot of information that will assist you.
0
 

Author Comment

by:FSAAdmin
ID: 33726427
I changed the name Level and now get a new error.  I have been researching Google.  I can appreicate your patience with "newbie" stuff.  

Microsoft Office Access Database Engine error '80040e14'

Syntax error (missing operator) in query expression ''Cervantes Village, Bldg A (Children's Village'.

This is the first field on the insert statement "Facility".
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33726532
Your error is in front of you.  Children's Village'  The single quote will kill the SQL.

You are asking a lot for 125 points my friend...  Almost all of your errors can be fixed with a simple Google search on the error number and message.
0
 

Author Comment

by:FSAAdmin
ID: 33727388
I apologize as I said I'm a newbie to this forum also.  I've increased the number of points to 500.   I realized that I will need to clean up some data.

NSERT INTO NotedIssues (Facility, Shop, Location, NotLevel, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES (Beef Office','Administration','','',' ',' BJ Maestas','','', '',' ','009.jpg','','','','Service Affecting','','','','BRR)

Microsoft Office Access Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'Beef Office','Administration','','',' ',' BJ Maestas','','', '',' ','009.jpg','','','','Service Affecting','','','','BRR'.
MySQLStatement = "INSERT INTO NotedIssues (Facility, Shop, Location, NotLevel, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ("& FACILITY &"','"& shop2 & "','"& Location &"','"& NotLevel&"',' "&	Facility_Component&"',' "& Employee_Adding_Issue&"','"& Type_of_Equipment&"','"& Issue&"', '"&Required_Correction&"',' "& Additional_Information&"','"& Attachment &"','"& Index_Number&"','"& AIM_WO&"','"& Funding_Approved&"','"& Correction_Priority&"','"& Correction_Estimated_Start&"','"& Estimate_Correction_Cost&"','"& Correction_Estimated_Complete&"','"& Funding2&")"

Open in new window

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33727515
Can you please do some reading before posting errors like this?  Go through a few pages at Google and correct whatever issues you might be having with the SQL.  This error is a common error and usually means that you are either trying to pass data that the field does not like or the field is required to have a certain type of data and is is not getting it.  Field types like Int and Date require proper formatting and delimiting.  If you use quotes around a integer for example you will get this error.  If the field is set to Int() and you try to pass it a string you will get an error.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33727546
Your missing quotes;  Also watch for spaces in the insert values, especially at the beginning of the value.

VALUES ('Beef Office','Administration','','','','BJ Maestas','','', '','','009.jpg','','','','Service Affecting','','','','BRR')
0
 

Author Comment

by:FSAAdmin
ID: 33731413
Well I'm getting closer. I'm able to upload a file and insert a record into the database.  However, it seems that all fields are being required.  

I will "GOOGLE" a solution, but if you know one, pleae let me know.  
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33731464
You should either sent a " " value to the database, or correct the database itself to not require data on the fields.  Or at the minimum, set a default value on the fields inside the database.
0
 

Author Comment

by:FSAAdmin
ID: 33746404
Now I still have a problem where I can’t insert empty/blank values into the database.  What am I doing wrong?  Everything works if I populate all my fields with data on the form.  I’ve already set the fields on the database to not be required.  It also works if I put an initial value on the form but it doesn't like "" so I tried putting in null and it save the text as null.

I feel so close but so far away.  

Dim FACILITY, shop2, Location, NotLevel, Facility_Component, Employee_Adding_Issue, Type_of_Equipment, Issue, Required_Correction, Additional_Information, Attachment, Index_Number, AIM_WO, Funding_Approved, Correction_Priority, Correction_Estimated_Start, Estimate_Correction_Cost, Correction_Estimate_Complete, Funding2

	

	



				

				FACILITY = Upload.Form("Facility") 

				response.write(Facility)

				shop2 = Upload.Form("shop2") 

				response.write(shop2)

				Location = Upload.Form("Location")

				response.write(Location)

				NotLevel = Upload.Form("NotLevel") 

				response.write(NotLevel)

				Facility_Component = Upload.Form("Facility_Component") 

				response.write(Facility_Component)

				Employee_Adding_Issue = Upload.Form("Employee_Adding_Issue") 

				response.write(Employee_Adding_Issue)

				Type_of_Equipment = Upload.Form("Type_of_Equipment") 

				response.write(Type_of_Equipment)

				Issue = Upload.Form("Issue") 

				response.write(Issue)

				Required_Correction = Upload.Form("Required_Correction") 

				response.write(Required_Correction)

				Additional_Information = Upload.Form("Additional_Information") 

				response.write(Additional_Information)

				Attachment = Upload.Form("Attachment") 

				response.write(Attachment)

				Index_Number = Upload.Form("Index_Number") 

				response.write(Index_Number)

				AIM_WO = Upload.Form("AIM_WO") 

				response.write(AIM_WO)

				Funding_Approved = Upload.Form("Funding_Approved") 

				response.write(Funding_Approved)

				Correction_Priority = Upload.Form("Correction_Priority") 

				response.write(Correction_Priority)

				Correction_Estimated_Start = Upload.Form("Correction_Estimated_Start") 

				response.write(Correcdtion_Estimated_Start)

				Estimate_Correction_Cost = Upload.Form("Estimate_Correction_Cost") 

				response.write(Estimate_Correction_Cost)

				Correction_Estimated_Complete= Upload.Form("Correction_Estimated_Complete") 

				response.write(Correction_Estimated_Complete)

				Funding2= Upload.Form("Funding2") 

				response.write(Funding2)



MySQLStatement = "INSERT INTO NotedIssues (Facility, Shop, Location, NotLevel, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ('"&FACILITY&"','"&shop2&"','"&Location&"','"&NotLevel&"','"&Facility_Component&"','"&Employee_Adding_Issue&"','"&Type_of_Equipment&"','"&Issue&"', '"&Required_Correction&"','"&Additional_Information&"','"&Attachment&"','"&Index_Number&"','"&AIM_WO&"',"&Funding_Approved&",'"&Correction_Priority&"',#"&Correction_Estimated_Start&"#,'"&Estimate_Correction_Cost&"',#"&Correction_Estimated_Complete&"#,'"&Funding2&"')"







		Response.Write (MySQLStatement)

			

			

	Set MyConnection = Server.CreateObject("ADODB.Connection")

				MyConnection.Open MyConnectionString

				MyConnection.Execute(MySQLStatement)

				MyConnection.Close()

				

				Response.Write ("Record inserted")

				Set MyConnection = Nothing

Open in new window

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33746948
Where are you getting the error?  On the Execute line?  What is the error?  
0
 

Author Comment

by:FSAAdmin
ID: 33747147
Yes on the execute line

Microsoft Office Access Database Engine error '80040e07'

Syntax error in date in query expression '#'.

/FacilityConditionTracking/bj4insert.asp, line 618
0
 

Author Comment

by:FSAAdmin
ID: 33747189
I can save the record as long as I select the checkbox and enter a date in the two date fields.  The rest of the fields are fine being empty.

I have read numerous articles about not using single quotes around variables that are tied to checkboxes and dates.  This works fine as long as there is a value.  But if it is empty/blank then I can't hit the database.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 33747820
Checkbox values are boolean type data, you need to verify that the value being passed is either a 1 or a 0, true or false.  Boolean data type don't require single quotes like string/text data type also.   As for the date field, if the date is not passed to the .asp correctly, you will have to format the date so that the db will accept it.  What is the field type in the database for both the checkbox and date data?

Do a response.write on the MySQLStatement and post the results with the checkbox and date populated and without.
0
 

Author Comment

by:FSAAdmin
ID: 33747905
I was troubleshooting and created a response.write statement on all the fields.....

Results without checkbox and date (with error message)

Fulton Athletic Center (Stadium Annex)AdministrationAmezquita, Esther F.000.jpgService AffectingBRR

INSERT INTO NotedIssues (Facility, Shop, Location, NotLevel, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ('Fulton Athletic Center (Stadium Annex)','Administration','','','','Amezquita, Esther F.','','', '','','000.jpg','','',,'Service Affecting',##,'',##,'BRR')

Microsoft Office Access Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/FacilityConditionTracking/bj4insert.asp, line 625


Checkbox checked and dates entered

Fulton Athletic Center (Stadium Annex)AdministrationAmezquita, Esther F.000.jpg1Service Affecting9/1/109/2/10BRR

INSERT INTO NotedIssues (Facility, Shop, Location, NotLevel, FacilityComponent, EmployeeAddingIssue, TypeofEquipment, Issue, RequiredCorrection, AdditionalInformation, Attachment, IndexNumber, AIMWO, FundingApproved, CorrectionPriority, CorrectionEstimatedStart, EstimateCorrectionCost, CorrectionEstimatedComplete, Funding) VALUES ('Fulton Athletic Center (Stadium Annex)','Administration','','','','Amezquita, Esther F.','','', '','','000.jpg','','',1,'Service Affecting',#9/1/10#,'',#9/2/10#,'BRR')Record insertedFiles uploaded: 000.jpg (202962B)
0
 
LVL 18

Assisted Solution

by:mgfranz
mgfranz earned 500 total points
ID: 33748019
OK, it looks like the checkbox value is not being set to a "0" when it isn't checked, write a simple If..Else on the Request() for the checkbox;

If varCheckbox <> 1 Then
    varCheckbox = 0
End If

For the date value, ensure that the field in the database allow a NULL or None value, if not, you could insert a default date into the field by using another If..Else on the date var;

If varDate = "" Then
   varDate = Date()  ' This will force today to be entered into the db
End If

I'm guessing that the db is setup to require a Date value.  How are you requesting the date field in the form?
0
 

Author Comment

by:FSAAdmin
ID: 33748338
Adding the if statement to set the value to "0" worked.  

Moving on to the date.

THe field in the database is Date/Time: Format=Short Date:  Required=No: Indexed=No: IME Mode = No Control: IME Sentence Mode=None: Text Align = General : Show Date PIcker = Never

I don't have the option to allow null on this filed like the other fields.  The two date fields are for estimated start date and the actual completion date.  The user will enter the completion date when the item has been completed and not at the time of initial data entry.  

I don't think putting in today's date would work for the completion date.
0
 
LVL 18

Assisted Solution

by:mgfranz
mgfranz earned 500 total points
ID: 33749380
Hmm...  You could require the user to enter an estimated date value on the fields or simply create a default date of "00/00/00", and then in the display of the data table use a catch that omits the field null, something like this;  

valDate = Request("datefield from form")

If valDate = "" Then
   valDate = "00/00/00"
End If

Then in the display page, do this on the record field;

valTheDate = rs("theDate")
If valTheDate = "00/00/00" Then
   valTheDate = ""
End If

This way the date field will not be displayed on the results page.

0
 

Author Closing Comment

by:FSAAdmin
ID: 33757053
Thank you so much for you help and patience with a newbie.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now