Using Vbscript "SPLIT" function on Multi-select field

P

pmarisole

I am trying to split a mgrgroup field to extract the MD codes.
It correctly grabs the MD codes if all records in a mass update
are updated, but if only one record in the loop is updated then
it puts the last 5 digits of the mgr name in the MD field.

THIS IS THE CODE:
if len(request.form("Proj"))> 0 then
for each strID in request.form("Proj")
mgrgrp=""
mdgrp=""

if len(request.form("mgrgroup_" & strID)) > 0 then
Redim arMgrs(request.form("mgrgroup_" & strID).Count -1)
i = 0
for each strMgr in request.form("mgrgroup_" & strID)
arMgrs(i)=RTrim(split(strMgr,"-")(0))
i = i + 1
next
mgrgrp=Join(arMgrs,", ")

Redim arMds(request.form("mgrgroup_" & strID).Count -1)
i = 0
for each strMd in request.form("mgrgroup_" & strID)
arMds(i)= right(split(strMd,",")(0), 5)
i = i + 1
next
mdgrp=Join(arMds,",")
end if

mySQL = "UPDATE EBSProjects SET mgrgroup= '" & trim(mgrgrp) & "',
mdgroup= '" & trim(mdgrp) & "' where (ebsrefid ='" & strID & "')"
dbProject.Execute(mySQL)
next
end if


THIS IS THE 1st RECORD IN THE LOOP AND THE USER MODIFIES IT
This record is updated correctly by putting
A Sanders, B Bennett in the MgrGroup field and
RTB, TPP in the MdGroup field

The MgrGroup field contains: A Sanders, B Bennett
The MdGROUP field contains: RTB, TPP


THIS IS THE 2ND RECORD IN THE LOOP AND THE USER DOES NOT MODIFY IT
So it overwrites the correct values from the initial time it
was updated and puts in the last 5 digits of the manager name
into the MdGROUP field.

The MgrGroup field contains: A Sanders
The MdGROUP field contains: nders

The SQL Statement
UPDATE EEEProjects SET mgrgroup= 'A Sanders',
mdgroup= 'nders' where (eeerefid ='60691908')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top