DATABASE Access

Associate
Joined
6 Jun 2004
Posts
93
Location
London
I have a feild in my Access DB which should only hold percentage values. When i submit my form example 90 should be 90% but its writing it as 900.00%. I've tried everything in settting the data types and things like that.

Does anyone have a suggestion as to how I can limit it to one decimal place ie. 33.3% instead of 3300.3000%

thanks for any help in advance!
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
ASP.net or ASP classic and what control are you using for your text box?

please don't expect access to be able to support more than 1 or 2 web users at a time.

You 'should' be able to set a filter on the text box in ASP but It's not my area of expertise. Can you add code to the on exit or on key down triggers in ASP to manage the validation?

It sound't to me like somewhere in your form you are managing to mangle the data. the string from the control should be checked (IS_NUMERIC() I think) and then added to the DB intact, so it will go in as 90 or 0.9 or 90.9 whatever the user has entered. The form should reject entries that are > 100 or < 0 oand probably round any decimals to 1 or 2 DP (whatever you want to store). You can then set constraints on your database to prevent values > 100 or < 1 or with more than 2 dp being stored in the database.

perhaps a messagebox in the form just before it sends it back to the DB to let you know what value it's about to save would help.

HT
 
Associate
OP
Joined
6 Jun 2004
Posts
93
Location
London
<%
Option explicit
dim PageTitle, Step
PageTitle = "Step " & Step
%>
<!--#include virtual ="/script/breadcrumb.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Internal Recruitment Procedure - Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Form">
<meta name="Keywords" content="">
<meta name="Robots" content="index"><!-- Set to 'index' or 'noindex' as required -->
<meta name="Author" content="">
<script language="JavaScript">
function fieldEnable(field){
field.disabled = false;
field.style.background = "#ffffff";
}

function fieldDisable(field){
field.disabled = true;
field.style.background = "#dddddd";
}
</script>
<script language="JavaScript"><!-- This script does the percentage calculation for costcode-->
function calc1(field) {
If not Costcode1 ="" Then
percent1 = "100%"
end if
}

</script>
<link href="/script/global.css" rel="stylesheet" type="text/css">
<link href="/script/procedures.css" rel="stylesheet" type="text/css">
</head>
<body onload="fnSetDefaults()">
<!--#include virtual="/menu/pageTop.asp"-->
<!-- #include virtual="/menu/lmBlank.inc"--><!-- Local navigation menu -->
</td>
<td class="tdContent" valign="top">
<div style="background:transparent; height:21px;"><img src="/image/spacer.gif" width="540" height="21" border="0" alt=""></div>
<div class="divIntroText">Where am I? <% = BreadCrumb(Request.ServerVariables("PATH_INFO")) %></div>
<div class="divContent">
<!-- Page content -->

<script language="JavaScript1.2" type="text/javascript">
<!--

function SubmitClaim(){
var msgWin = showModalDialog("submitClaim.htm",null,"status:no;center:yes;help:no;minimize:no;maximize:no;border:thin;statusbar:no;dialogWidth:300px;dialogHeight:225px")
}
//-->
</script>
<p>&nbsp;</p>
<form method="post" action="t1formsadd.asp" name="t1forms" onSubmit="SubmitClaim()">
<table class="tblData" cellspacing="2" cellpadding="3" border="0" ID="Table1" width="600">

<tr>
<td class="tdBorder" colspan="4">&nbsp;</td>
</tr>

<tr>
<td width="130" class="tdBorder">Enter your Job Title</td>
<td width="144" class="tdBorder"><input type=text name="JobTitle"></td>
<td width="106" class="tdBorder">&nbsp;</td>
<td width="186" class="tdBorder">&nbsp; </td>
</tr>
<tr>
<td class="tdBorder">Enter Location</td>
<td class="tdBorder"><input type=text name="Location"></td>
<td class="tdBorder">&nbsp;</td>
<td class="tdBorder">&nbsp; </td>
</tr>
<tr>
<td class="tdBorder">Minimum Salary </td>
<td class="tdBorder"><input type=number name="MiSalary"></td>
<td class="tdBorder">Maximum Salary</td>
<td class="tdBorder"><input type=number name="MxSalary"></td>
</tr>
<tr>
<td class="tdBorder">Intranet Job Description</td>
<td class="tdBorder" colspan="3"><textarea name="IJD" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td class="tdBorder">Cost Code one </td>
<td class="tdBorder"><input type=number name="costcode1" onFocus="calc1(percent1)"></td>
<td class="tdBorder">Allocation one </td>
<td class="tdBorder"><input type= IS_NUMERIC() name="percent1"></td>
</tr>
<tr>
<td class="tdBorder">Cost Code two </td>
<td class="tdBorder"><input type=number name="costcode2" onFocus="calc11(percent2)"></td>
<td class="tdBorder">Allocation two</td>
<td class="tdBorder"><input type=number name="percent2"></td>
</tr>
<tr>
<td class="tdBorder">Cost Code three </td>
<td class="tdBorder"><input type=number name="costcode3"></td>
<td class="tdBorder">Allocation three</td>
<td class="tdBorder"><input type=number name="percent3"></td>
</tr>
<tr>
<td class="tdBorder"></td>
<td class="tdBorder" colspan="2" align="right">Total</td>
<td class="tdBorder"><input type=number name="TotalAll"></td>
</tr>
<tr>
<td class="tdBorder">New Position</td>
<td class="tdBorder" colspan="3"><input type="radio" name="NewP" value="Yes" onClick="fieldDisable(ReplacementBox)">Yes&nbsp;&nbsp;<input type="radio" name="NewP" value="No" onClick="fieldEnable(ReplacementBox)">
No (If &quot;NO&quot;, please complete replacement details below) </td>
</tr>
<tr>
<td class="tdBorder">Replacement</td>
<td class="tdBorder" colspan="3">*Name, Job Tile and Salary of employee being replaced.
<textarea name="ReplacementBox" cols="55" rows="5" value="N/A" disabled style="background:#dddddd"> </textarea></td>
</tr>
<tr>
<td class="tdBorder">Position Budgeted</td>
<td class="tdBorder" colspan="3"><input type="radio" name="Pbudget" value="Yes"> Yes &nbsp;&nbsp; <input type="radio" name="Pbudget" value="No"> No</td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input type="submit" value="Submit claim" class="Button" width="90px">&nbsp;&nbsp;
<input type=reset value="Reset" class="Button" width="90px">
</div></td>
</tr>
<tr>
<td colspan="4"><span class="tdBorder">
</span></td>
</tr>

</table>
</form>


<!-- End page content -->
</div>
<div class="divIntroText">Where am I? <% = BreadCrumb(Request.ServerVariables("PATH_INFO")) %></div>
<!--#include virtual="/menu/PageBottom.inc"-->
</body></html>
 
Associate
OP
Joined
6 Jun 2004
Posts
93
Location
London
Hi HT,

thanks for you help. As suggested i've posted my code above! I am struggling with Allocation one, two and three feilds. Basically its a number feild which will hold percentage values, which will automatically will be calculated. What i want is that when a form is submitted it writes whatever is in the Allocation field to the DB. At the moment if i enter 10% its writing 1000% in DB.

All Feilds in DB are also numaric! please let me know what to do!

thanks
Tushar
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
bleurgh that looks like ASP code to me which is something that I know NOTHING about.....

looks a bit like PHP though :D

Sorry, I'm a backend C / C# / Java / database programmer and really don't know where to start when it comes to javascript stuff...

and that's an auful lot of code to post on a web forum expecting unpaid people to read and debug ;)

HT
 
Back
Top Bottom