帮助计算多个记录 [英] Help with Calculation of Multiple Records

查看:79
本文介绍了帮助计算多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在下拉框中收集数据的页面,其中

值为1-10,并将其发送到提交的页面进行计算。

示例:

Employee1 TeamScore(1-10)

Employee2 TeamScore(1-10)

Employee3 TeamScore(1-10)

Employee4 TeamScore(1-10)

然后我提交此页面,其中包含TeamScore中每个

员工的所有值,我想要

根据下拉列表中的值执行计算,并从另一个

数据库表中执行

加权分数。加权分数的一个例子是0.11,我需要

将每个雇员的加权分数0.11加倍(从1到10)乘以




我有几条记录可以从上一个屏幕一次更新

包含数字1到10的下拉框我想带每个

单个下拉值并乘以加权分数(即

0.11等)

运行此代码时出现以下错误消息下面:

Microsoft VBScript运行时错误''800a000d''


类型不匹配:''[string:""]''


<%

MLevel2 =" 0"

''On Error Resume Next

设置C9 = Server.CreateObject(" ADODB.Connection")

C9.Open" Provider = sqloledb; Data

Source = ebs-sqlc1-vs3.edn.runi.com \ SSS; UID = casuser; PWD = hppccas; DATAB ASE =技能"

设置rsScors = Server.CreateObj ect(ADODB.Recordset)

sSQ5 ="从WgtScore中选择*,其中org =''" &安培;会话(orgg)& "''

AND mgmtlevel =''" &安培; MLevel2& "''"

rsScors.Open sSQ5,C9,adOpenKeySet,adLockReadOnly,adCmdText

D5 = rsScors(" QDiv5")

SS5 =0.0

S11 = round(rsScors(" WS1"),2)

rsScors.close

set rsScors = Nothing

strID = split(request.form(" Emp)),",")

QQ1 = split(request.form(" Q1" ;)* S11,",")

FOR i = LBound(strID)TO UBound(strID)

sSQL =" UPDATE EDNCurr SET Q1 ='' " &安培;修剪(QQ1(i))& "''where(empid =''"

& strID(i)&"'')"

C9.Execute(sSQL)

NEXT

C9.关闭

设置C9 =无什么

%>

我无法弄清楚如何使这个计算工作。任何帮助都会非常感激。

解决方案



< 60***@fedex.com写信息

新闻:11 ********************** @ j44g2000cwa.googlegr psps.com ...


这是我在下拉框中收集数据的页面,其中

值为1-10并发送给它到提交的页面进行计算。

例如:

Employee1 TeamScore(1-10)

Employee2 TeamScore(1-10)

Employee3 TeamScore(1-10)

Employee4 TeamScore(1-10)

然后我提交此页面,其中包含TeamScore中的所有值

员工,我想

根据下拉列表中的值和另一个

加权分数进行计算

数据库表。加权分数的一个例子是0.11,我需要

将每个雇员的加权分数0.11加倍(从1到10)乘以




我有几条记录可以从上一个屏幕一次更新

包含数字1到10的下拉框我想带每个

单个下拉值并乘以加权分数(即

0.11等)


我收到以下错误消息时我在下面运行以下代码:

Microsoft VBScript运行时错误''800a000d''


类型不匹配:''[string:""]''


<%

MLevel2 =" 0"

''On Error Resume Next

设置C9 = Server.CreateObject(" ADODB.Connection")

C9.Open" Provider = sqloledb; Data

Source = ebs-sqlc1-vs3.edn .runi.com \ nsS; UID = casuser; PWD = hppccas; DATAB ASE =技能"

设置rsScors = Server.Create对象(ADODB.Recordset)

sSQ5 ="从WgtScore中选择*,其中org =''" &安培;会话(orgg)& "''

AND mgmtlevel =''" &安培; MLevel2& "''"

rsScors.Open sSQ5,C9,adOpenKeySet,adLockReadOnly,adCmdText

D5 = rsScors(" QDiv5")

SS5 =0.0

S11 = round(rsScors(" WS1"),2)

rsScors.close

set rsScors = Nothing


strID = split(request.form(" Emp"),",")

QQ1 = split(request.form (Q1)* S11,",")

FOR i = LBound(strID)TO UBound(strID)

sSQL =" UPDATE EDNCurr SET Q1 =''" &安培;修剪(QQ1(i))& "''where(empid =''"

& strID(i)&"'')"

C9.Execute(sSQL)

NEXT

C9.关闭

设置C9 =无什么

%>


我无法弄清楚如何使这个计算工作。任何帮助都会非常感激。



你没有说错误发生在哪里,但你可能正在努力

对目前为字符串的变量执行数值运算。

尝试使用合适的转换函数 - Cint,Cdbl,Clng。

等待 - 什么是QQ1 =拆分(request.Form(" Q1")* S11,",")?如果

Request.Form(" Q1")是逗号分隔的字符串,则不能将它乘以

任何东西。使用Split后,您需要分别对数组中的每个项目执行乘法运算

。您可能还需要将每个项目转换为

数字,以执行上面建议的乘法。类似于:


<%

strID = split(request.form(" Emp"),",")

QQ1 =拆分(request.form(" Q1"),",")

FOR i = LBound(strID)TO UBound(strID)

MyNum = Clng(QQ1(i))* S11''可能是cint或cdbl,取决于QQ1(i)

sSQL =" UPDATE EDNCurr SET Q1 =''" &安培; MyNum& "''where(empid =''"

& strID(i)&"'')"

C9.Execute(sSQL)

NEXT

%>


-

Mike Brind


Mike,

我已经将上面的代码合并而且效果很好,除了

类别5,用户可以使用

选择N / A。或1-10的值。即使我选择1-10的值,它也会自动计算第5类中的N / A

,但它会在数据库表中捕获正确的值

。这是第一个问题,并且

我不确定如何修复它。


以下是代码现在的样子:

MLevel2 =" 0"

On Error Resume Next

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

C9.OpenProvider = sqloledb; Data

Source = ebs-sqlc1-vs3.edn.runi.com\SSS; UID = casuser; PWD = hppccas; DATAB ASE =技能

设置rsScors = Server.CreateObject(" ADODB.Recordset")

sSQ5 ="从WgtScore中选择*,其中org =''" &安培;会话(orgg)& "''

AND mgmtlevel =''" &安培; MLevel2& "''"

rsScors.Open sSQ5,C9,adOpenKeySet,adLockReadOnly,adCmdText

D5 = rsScors(" QDiv5")

S11 = round(rsScors(WS1),2)

S22 = round(rsScors(" WS2"),2)

S33 = round(rsScors (WS3),2)

S44 = round(rsScors(" WS4"),2)

S55 = round(rsScors(" WS5")) ,2)

S66 = round(rsScors(WS6),2)

S77 = round(rsScors(" WS7"),2)
S88 = round(rsScors(WS8),2)

S99 = round(rsScors(" WS9"),2)


strID = split(request.form(" Emp)),",")

QQ1 = split(request.form(" Q1"),"," )

QQ2 =拆分(request.form(" Q2"),",")

QQ3 =拆分(request.form(" Q3")) ,")

QQ4 =拆分(request.form(" Q4"),",")

QQ5 =拆分(request.form (QUOT; Q5&现状t;),,"

QQ6 =拆分(request.form(" Q6"),",")

QQ7 =拆分( request.form(" Q7"),",")

QQ8 = split(request.form(" Q8"),",")

QQ9 = split(request.form(" Q9"),",")


FOR i = LBound(strID)TO UBound(strID)

Q11 = Clng(QQ1(i))* S11

Q22 = Clng(QQ2(i))* S22

Q33 = Clng(QQ3(i) )* S33

Q44 = Clng(QQ4(i))* S44

如果(QQ5 =N / A)那么

Q55 =N / A

其他

Q55 = Clng(QQ5(i))* S55

结束如果

Q66 = Clng(QQ6(i))* S66

Q77 = Clng(QQ7(i))* S77

Q88 = Clng(QQ8(i) )* S88

Q99 = Clng(QQ9(i))* S99

如果(QQ5 =N / A)那么

QS =((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99)/ D5)

其他

QS = round((Q11 + Q22 + Q33) + Q44 + Q55 + Q66 + Q77 + Q88 + Q99),2)

结束如果


得分=拆分((QS(i)),,,)
我不认为得分字段是正确的SPLIT语法,因为它是
我执行它时
没有把它放在数据库表中。


sSQL =" UPDATE EDNCurr SET Q1 =''" &安培;修剪(QQ1(i))& '',Q2 =''" &

trim(QQ2(i))& '',Q3 =''" &安培;修剪(QQ3(i))& '',Q4 =''" &安培;修剪(QQ4(i))&

"'',Q5 =''" &安培;修剪(QQ5(i))& '',Q6 =''" &安培;修剪(QQ6(i))& '',Q7 =''" &

trim(QQ7(i))& '',Q8 =''" &安培;修剪(QQ8(i))& '',Q9 =''" &安培;修剪(QQ9(i))&

"'',FY07Score =''" &安培;修剪(分数(i))& "''where(empid =''"& strID(i)&

"'')"

C9.Execute(sSQL)

NEXT


****************************** ******************** ****************************** ***************

这是我运行时的response.write输出值:

SQL语句是:

UPDATE EAPcurrentyear SET Q1 =''''',Q2 =''3'',Q3 =''''',Q4 ='''4'',

Q5 =''5'',Q6 =''4'',Q7 =''4'',Q8 ='''6'',Q9 ='''5''其中(empid ='''118694'')


Q11 = 0.66

Q22 = 0.33

Q33 = 0.55

Q44 = 0.44

Q55 = N / A

Q66 = 0.44

Q77 = 0.44

Q88 = 0.66

Q99 = 0.55

分数= 4.58

正如您所看到的,Q5字段中的值为5,但计算结果为
" N / A"它计算错误的分数。计算结果是,在字段5中分配N / A的所有值。无论

用户选择什么价值,所以它只计算8个类别,而不是9

,即使字段5中的值为1-10。 br />

最后,我要将更新发回到提交的页面,其中

计算出的分数显示但我不想显示分数所有

已选择9个类别值。我确实希望它将

个别类别值添加到数据库表中,只是不允许

用户在屏幕上看到最终得分,直到所有类别都

为每位员工分配一个值。


您一直非常乐于助人,我几乎只有一些调整。

我非常感谢你的指导。我是新来的,而且太糟糕了。
不堪重负。非常感谢你的帮助....这将减轻负担

我。


迈克,
我已经将上面的代码合并而且效果很好,除了在

类别5中,用户被允许

选择N / A。或1-10的值。即使我选择1-10的值,它也会自动计算第5类中的N / A

,但它会在数据库表中捕获正确的值

。这是第一个问题,并且

我不确定如何修复它。


以下是代码现在的样子:

MLevel2 =" 0"

On Error Resume Next

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

C9.OpenProvider = sqloledb; Data

Source = ebs-sqlc1-vs3.edn.runi.com\SSS; UID = casuser; PWD = hppccas; DATAB ASE =技能

设置rsScors = Server.CreateObject(" ADODB.Recordset")

sSQ5 ="从WgtScore中选择*,其中org =''" &安培;会话(orgg)& "''

AND mgmtlevel =''" &安培; MLevel2& "''"

rsScors.Open sSQ5,C9,adOpenKeySet,adLockReadOnly,adCmdText

D5 = rsScors(" QDiv5")

S11 = round(rsScors(WS1),2)

S22 = round(rsScors(" WS2"),2)

S33 = round(rsScors (WS3),2)

S44 = round(rsScors(" WS4"),2)

S55 = round(rsScors(" WS5")) ,2)

S66 = round(rsScors(WS6),2)

S77 = round(rsScors(" WS7"),2)
S88 = round(rsScors(WS8),2)

S99 = round(rsScors(" WS9"),2)


strID = split(request.form(" Emp)),",")

QQ1 = split(request.form(" Q1"),"," )

QQ2 =拆分(request.form(" Q2"),",")

QQ3 =拆分(request.form(" Q3")) ,")

QQ4 =拆分(request.form(" Q4"),",")

QQ5 =拆分(request.form (QUOT; Q5&现状t;),,"

QQ6 =拆分(request.form(" Q6"),",")

QQ7 =拆分( request.form(" Q7"),",")

QQ8 = split(request.form(" Q8"),",")

QQ9 = split(request.form(" Q9"),",")


FOR i = LBound(strID)TO UBound(strID)

Q11 = Clng(QQ1(i))* S11

Q22 = Clng(QQ2(i))* S22

Q33 = Clng(QQ3(i) )* S33

Q44 = Clng(QQ4(i))* S44

如果(QQ5 =N / A)那么

Q55 =N / A

其他

Q55 = Clng(QQ5(i))* S55

结束如果

Q66 = Clng(QQ6(i))* S66

Q77 = Clng(QQ7(i))* S77

Q88 = Clng(QQ8(i) )* S88

Q99 = Clng(QQ9(i))* S99

如果(QQ5 =N / A)那么

QS =((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99)/ D5)

其他

QS = round((Q11 + Q22 + Q33) + Q44 + Q55 + Q66 + Q77 + Q88 + Q99),2)

结束如果


得分=拆分((QS(i)),,,)
我不认为得分字段是正确的SPLIT语法,因为它是
我执行它时
没有把它放在数据库表中。


sSQL =" UPDATE EDNCurr SET Q1 =''" &安培;修剪(QQ1(i))& '',Q2 =''" &

trim(QQ2(i))& '',Q3 =''" &安培;修剪(QQ3(i))& '',Q4 =''" &安培;修剪(QQ4(i))&

"'',Q5 =''" &安培;修剪(QQ5(i))& '',Q6 =''" &安培;修剪(QQ6(i))& '',Q7 =''" &

trim(QQ7(i))& '',Q8 =''" &安培;修剪(QQ8(i))& '',Q9 =''" &安培;修剪(QQ9(i))&

"'',FY07Score =''" &安培;修剪(分数(i))& "''where(empid =''"& strID(i)&

"'')"

C9.Execute(sSQL)

NEXT


****************************** ******************** ****************************** ***************

这是我运行时的response.write输出值:

SQL语句是:

UPDATE EAPcurrentyear SET Q1 =''''',Q2 =''3'',Q3 =''''',Q4 ='''4'',

Q5 =''5'',Q6 =''4'',Q7 =''4'',Q8 ='''6'',Q9 ='''5''其中(empid ='''118694'')


Q11 = 0.66

Q22 = 0.33

Q33 = 0.55

Q44 = 0.44

Q55 = N / A

Q66 = 0.44

Q77 = 0.44

Q88 = 0.66

Q99 = 0.55

分数= 4.58

正如您所看到的,Q5字段中的值为5,但计算结果为
" N / A"它计算错误的分数。计算结果是,在字段5中分配N / A的所有值。无论

用户选择什么价值,所以它只计算8个类别,而不是9

,即使字段5中的值为1-10。 br />

最后,我要将更新发回到提交的页面,其中

计算出的分数显示但我不想显示分数所有

已选择9个类别值。我确实希望它将

个别类别值添加到数据库表中,只是不允许

用户在屏幕上看到最终得分,直到所有类别都

为每位员工分配一个值。


您一直非常乐于助人,我几乎只有一些调整。

我非常感谢你的指导。我是新来的,而且太糟糕了。
不堪重负。非常感谢你的帮助....这将减轻负担

我。


This is the page where I collect the data in drop-down boxes with
values of 1-10 and send it to a submitted page to do calculations.
Example:
Employee1 TeamScore(1-10)
Employee2 TeamScore(1-10)
Employee3 TeamScore(1-10)
Employee4 TeamScore(1-10)
Then I submit this page with all the values in TeamScore for every
employee and I want to
perform a calculation based on the values in the drop-down and a
weighted score from another
database table. An example of a weighted score is 0.11 and I need to
multiply the value(from 1 to 10) times the weighted score of 0.11 for
each employee.

I have several records to update all at once from the previous screen
of drop-down boxes containing numbers 1 - 10 and I want to take each
individual drop-down value and multiply it by a weighted score (i.e.
0.11 etc.)
I am getting the following error message when I run this code below:
Microsoft VBScript runtime error ''800a000d''

Type mismatch: ''[string: ""]''

<%
MLevel2 = "0"
''On Error Resume Next
Set C9 = Server.CreateObject("ADODB.Connection")
C9.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"
Set rsScors= Server.CreateObject("ADODB.Recordset")
sSQ5 = "Select * from WgtScore where org = ''" & session("orgg") & "''
AND mgmtlevel = ''" & MLevel2 & "''"
rsScors.Open sSQ5, C9, adOpenKeySet,adLockReadOnly, adCmdText
D5 = rsScors("QDiv5")
SS5 = "0.0"
S11 = round(rsScors("WS1"),2)
rsScors.close
set rsScors = Nothing
strID = split(request.form("Emp"), ", ")
QQ1 = split(request.form("Q1")* S11,",")
FOR i = LBound(strID) TO UBound(strID)
sSQL = "UPDATE EDNCurr SET Q1= ''" & trim(QQ1(i)) & "'' where (empid =''"
& strID(i) & "'')"
C9.Execute(sSQL)
NEXT
C9.Close
Set C9 = Nothing
%>
I can''t figure out how to make this calculation work. Any help would
be Greatly appreciated.

解决方案


<60***@fedex.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...

This is the page where I collect the data in drop-down boxes with
values of 1-10 and send it to a submitted page to do calculations.
Example:
Employee1 TeamScore(1-10)
Employee2 TeamScore(1-10)
Employee3 TeamScore(1-10)
Employee4 TeamScore(1-10)
Then I submit this page with all the values in TeamScore for every
employee and I want to
perform a calculation based on the values in the drop-down and a
weighted score from another
database table. An example of a weighted score is 0.11 and I need to
multiply the value(from 1 to 10) times the weighted score of 0.11 for
each employee.

I have several records to update all at once from the previous screen
of drop-down boxes containing numbers 1 - 10 and I want to take each
individual drop-down value and multiply it by a weighted score (i.e.
0.11 etc.)
I am getting the following error message when I run this code below:
Microsoft VBScript runtime error ''800a000d''

Type mismatch: ''[string: ""]''

<%
MLevel2 = "0"
''On Error Resume Next
Set C9 = Server.CreateObject("ADODB.Connection")
C9.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"
Set rsScors= Server.CreateObject("ADODB.Recordset")
sSQ5 = "Select * from WgtScore where org = ''" & session("orgg") & "''
AND mgmtlevel = ''" & MLevel2 & "''"
rsScors.Open sSQ5, C9, adOpenKeySet,adLockReadOnly, adCmdText
D5 = rsScors("QDiv5")
SS5 = "0.0"
S11 = round(rsScors("WS1"),2)
rsScors.close
set rsScors = Nothing
strID = split(request.form("Emp"), ", ")
QQ1 = split(request.form("Q1")* S11,",")
FOR i = LBound(strID) TO UBound(strID)
sSQL = "UPDATE EDNCurr SET Q1= ''" & trim(QQ1(i)) & "'' where (empid =''"
& strID(i) & "'')"
C9.Execute(sSQL)
NEXT
C9.Close
Set C9 = Nothing
%>
I can''t figure out how to make this calculation work. Any help would
be Greatly appreciated.

You didn''t say where the error is ocurring, but you are probably trying to
perform a numeric operation on a variable that is a string at the moment.
Try using a suitable conversion function - Cint, Cdbl, Clng.

Hold on - What is QQ1 = split(request.Form("Q1")*S11,",") all about? If
Request.Form("Q1") is a comma-delimited string, you can''t multiply it by
anything. You need to perform the multiplication on each item in the array
separately after using Split. You may also need to convert each item to a
numeric to perform the multiplication as suggested above. Something like:

<%
strID = split(request.form("Emp"), ", ")
QQ1 = split(request.form("Q1"),",")
FOR i = LBound(strID) TO UBound(strID)
MyNum = Clng(QQ1(i))*S11 ''might be cint or cdbl depending on QQ1(i)
sSQL = "UPDATE EDNCurr SET Q1= ''" & MyNum & "'' where (empid =''"
& strID(i) & "'')"
C9.Execute(sSQL)
NEXT
%>

--
Mike Brind


Mike,
I have incorporated the code above and it works great except in
category 5 the user is allowed to
select an "N/A" or a value 1-10. It automatically calculates an "N/A"
in the 5th category even if I choose a value of 1-10 but it captures
the right value in the database table. That is the first problem and
I''m not sure how fix it.

Here is what the code looks like now:
MLevel2 = "0"
On Error Resume Next
Set C9 = Server.CreateObject("ADODB.Connection")
C9.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"
Set rsScors= Server.CreateObject("ADODB.Recordset")
sSQ5 = "Select * from WgtScore where org = ''" & session("orgg") & "''
AND mgmtlevel = ''" & MLevel2 & "''"
rsScors.Open sSQ5, C9, adOpenKeySet,adLockReadOnly, adCmdText
D5 = rsScors("QDiv5")
S11 = round(rsScors("WS1"),2)
S22 = round(rsScors("WS2"),2)
S33 = round(rsScors("WS3"),2)
S44 = round(rsScors("WS4"),2)
S55 = round(rsScors("WS5"),2)
S66 = round(rsScors("WS6"),2)
S77 = round(rsScors("WS7"),2)
S88 = round(rsScors("WS8"),2)
S99 = round(rsScors("WS9"),2)

strID = split(request.form("Emp"), ", ")
QQ1 = split(request.form("Q1"),",")
QQ2 = split(request.form("Q2"),",")
QQ3 = split(request.form("Q3"),",")
QQ4 = split(request.form("Q4"),",")
QQ5 = split(request.form("Q5"),",")
QQ6 = split(request.form("Q6"),",")
QQ7 = split(request.form("Q7"),",")
QQ8 = split(request.form("Q8"),",")
QQ9 = split(request.form("Q9"),",")

FOR i = LBound(strID) TO UBound(strID)
Q11 = Clng(QQ1(i))*S11
Q22 = Clng(QQ2(i))*S22
Q33 = Clng(QQ3(i))*S33
Q44 = Clng(QQ4(i))*S44
if (QQ5 = "N/A") Then
Q55 = "N/A"
else
Q55 = Clng(QQ5(i))*S55
end if
Q66 = Clng(QQ6(i))*S66
Q77 = Clng(QQ7(i))*S77
Q88 = Clng(QQ8(i))*S88
Q99 = Clng(QQ9(i))*S99
If (QQ5 = "N/A") THEN
QS = ((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99) / D5)
else
QS = round((Q11 + Q22 + Q33 + Q44 + Q55 + Q66 + Q77 + Q88 + Q99),2)
end if

Score = split((QS(i)),",")
I don''t think the Score field is the proper SPLIT syntax because it is
not putting it in the database table when I execute it.

sSQL = "UPDATE EDNCurr SET Q1= ''" & trim(QQ1(i)) & "'', Q2= ''" &
trim(QQ2(i)) & "'', Q3= ''" & trim(QQ3(i)) & "'', Q4= ''" & trim(QQ4(i)) &
"'', Q5= ''" & trim(QQ5(i)) & "'', Q6= ''" & trim(QQ6(i)) & "'', Q7= ''" &
trim(QQ7(i)) & "'', Q8= ''" & trim(QQ8(i)) & "'', Q9= ''" & trim(QQ9(i)) &
"'', FY07Score = ''" & trim(Score(i)) & "'' where (empid =''" & strID(i) &
"'')"
C9.Execute(sSQL)
NEXT

************************************************** *********************************************
Here is the response.write output values when I run it:
The SQL statement is:
UPDATE EAPcurrentyear SET Q1= ''6'', Q2= ''3'', Q3= ''5'', Q4= ''4'',
Q5= ''5'', Q6= ''4'', Q7= ''4'', Q8= ''6'', Q9= ''5'' where (empid =''118694'')

Q11 = 0.66
Q22 = 0.33
Q33 = 0.55
Q44 = 0.44
Q55 = N/A
Q66 = 0.44
Q77 = 0.44
Q88 = 0.66
Q99 = 0.55
Score= 4.58
As you can see the value in Q5 field is a 5 but the calculation sees it
as an "N/A" and it calculated the wrong Score. The calculation is
assigning all values in field 5 an "N/A" regardless of what value the
user selects so it only computes 8 categories all the time instead of 9
even when there is a value of 1-10 in field 5.

Finally, I am going to post the update back to the submitted page with
the calculated Score showing but I don''t want to show a score until all
9 category values have been selected. I do want it to add the
individual category values to the database table, just not allow the
user to see a final score on the screen until all categories have been
assigned a value per each employee.

You have been so helpful and I am almost there with just a few tweaks.
I really appreciate your guidance. I am new at this and fell sooooo
overwhelmed. THANKS SO MUCH FOR YOUR HELP....this will take a load off
me.


Mike,
I have incorporated the code above and it works great except in
category 5 the user is allowed to
select an "N/A" or a value 1-10. It automatically calculates an "N/A"
in the 5th category even if I choose a value of 1-10 but it captures
the right value in the database table. That is the first problem and
I''m not sure how fix it.

Here is what the code looks like now:
MLevel2 = "0"
On Error Resume Next
Set C9 = Server.CreateObject("ADODB.Connection")
C9.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"
Set rsScors= Server.CreateObject("ADODB.Recordset")
sSQ5 = "Select * from WgtScore where org = ''" & session("orgg") & "''
AND mgmtlevel = ''" & MLevel2 & "''"
rsScors.Open sSQ5, C9, adOpenKeySet,adLockReadOnly, adCmdText
D5 = rsScors("QDiv5")
S11 = round(rsScors("WS1"),2)
S22 = round(rsScors("WS2"),2)
S33 = round(rsScors("WS3"),2)
S44 = round(rsScors("WS4"),2)
S55 = round(rsScors("WS5"),2)
S66 = round(rsScors("WS6"),2)
S77 = round(rsScors("WS7"),2)
S88 = round(rsScors("WS8"),2)
S99 = round(rsScors("WS9"),2)

strID = split(request.form("Emp"), ", ")
QQ1 = split(request.form("Q1"),",")
QQ2 = split(request.form("Q2"),",")
QQ3 = split(request.form("Q3"),",")
QQ4 = split(request.form("Q4"),",")
QQ5 = split(request.form("Q5"),",")
QQ6 = split(request.form("Q6"),",")
QQ7 = split(request.form("Q7"),",")
QQ8 = split(request.form("Q8"),",")
QQ9 = split(request.form("Q9"),",")

FOR i = LBound(strID) TO UBound(strID)
Q11 = Clng(QQ1(i))*S11
Q22 = Clng(QQ2(i))*S22
Q33 = Clng(QQ3(i))*S33
Q44 = Clng(QQ4(i))*S44
if (QQ5 = "N/A") Then
Q55 = "N/A"
else
Q55 = Clng(QQ5(i))*S55
end if
Q66 = Clng(QQ6(i))*S66
Q77 = Clng(QQ7(i))*S77
Q88 = Clng(QQ8(i))*S88
Q99 = Clng(QQ9(i))*S99
If (QQ5 = "N/A") THEN
QS = ((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99) / D5)
else
QS = round((Q11 + Q22 + Q33 + Q44 + Q55 + Q66 + Q77 + Q88 + Q99),2)
end if

Score = split((QS(i)),",")
I don''t think the Score field is the proper SPLIT syntax because it is
not putting it in the database table when I execute it.

sSQL = "UPDATE EDNCurr SET Q1= ''" & trim(QQ1(i)) & "'', Q2= ''" &
trim(QQ2(i)) & "'', Q3= ''" & trim(QQ3(i)) & "'', Q4= ''" & trim(QQ4(i)) &
"'', Q5= ''" & trim(QQ5(i)) & "'', Q6= ''" & trim(QQ6(i)) & "'', Q7= ''" &
trim(QQ7(i)) & "'', Q8= ''" & trim(QQ8(i)) & "'', Q9= ''" & trim(QQ9(i)) &
"'', FY07Score = ''" & trim(Score(i)) & "'' where (empid =''" & strID(i) &
"'')"
C9.Execute(sSQL)
NEXT

************************************************** *********************************************
Here is the response.write output values when I run it:
The SQL statement is:
UPDATE EAPcurrentyear SET Q1= ''6'', Q2= ''3'', Q3= ''5'', Q4= ''4'',
Q5= ''5'', Q6= ''4'', Q7= ''4'', Q8= ''6'', Q9= ''5'' where (empid =''118694'')

Q11 = 0.66
Q22 = 0.33
Q33 = 0.55
Q44 = 0.44
Q55 = N/A
Q66 = 0.44
Q77 = 0.44
Q88 = 0.66
Q99 = 0.55
Score= 4.58
As you can see the value in Q5 field is a 5 but the calculation sees it
as an "N/A" and it calculated the wrong Score. The calculation is
assigning all values in field 5 an "N/A" regardless of what value the
user selects so it only computes 8 categories all the time instead of 9
even when there is a value of 1-10 in field 5.

Finally, I am going to post the update back to the submitted page with
the calculated Score showing but I don''t want to show a score until all
9 category values have been selected. I do want it to add the
individual category values to the database table, just not allow the
user to see a final score on the screen until all categories have been
assigned a value per each employee.

You have been so helpful and I am almost there with just a few tweaks.
I really appreciate your guidance. I am new at this and fell sooooo
overwhelmed. THANKS SO MUCH FOR YOUR HELP....this will take a load off
me.


这篇关于帮助计算多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆