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

Creating a form with multi select

P: n/a
hi,

I am trying to create a form where you may have more than one person
at a meeting, but want to have them be related to the same meeting.

I have a mulitple select text area and if you select more than one,
all the records are being added to the same row. so if I picked the
following three people:

(Person ID/Desc)
1 - mickey mouse
2 - donald duck
3 - goofy

The row in the data base would look like this:

(Meeting ID/ Person ID)

1 - 1,2,3

But I would like to do this:
(Meeting ID/ Person ID)
1 - 1
1 - 2
1 - 3

I hope this makes sense, if it does does anyone have a suggest on how
to best do this?

Jul 6 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
you'll need to show us what your code attempt has been, then others can show possible fix.
I hope this makes sense, if it does does anyone have a suggest on how
to best do this?

Jul 6 '07 #2

P: n/a
Hi,

I have created the following array:

Dim getPID
getPID = request.form("PID")

for i = 0 to getPID

oRS3.AddNew

oRS3.Fields("PID")=(request.form("PID" & i))

oRS3.Update
Next

However I am getting this error message:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "51, 69, 132, 112, 10"]'
Any thoughts? Thanks for all the help this far! =)

Kind Regards,

Ray

Jul 9 '07 #3

P: n/a
Ok So I working the split. Here is what I have for code:

Dim MyString, MyArray
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

response.write MyArray
I am getting this error message:

Response object error 'ASP 0106 : 80020005'
Type Mismatch
An unhandled data type was encountered.

Thanks for you help, thoughts, and pateince.

Jul 9 '07 #4

P: n/a
you can't write an array you must loop through an array and write each element.

For i = 0 to UBound(MyArray )
response.write MyArray(i) & "<br>" & vbcrlf
Next

"bcap" <ra**@patriots.comwrote in message news:11**********************@o61g2000hsh.googlegr oups.com...
Ok So I working the split. Here is what I have for code:

Dim MyString, MyArray
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

response.write MyArray
I am getting this error message:

Response object error 'ASP 0106 : 80020005'
Type Mismatch
An unhandled data type was encountered.

Thanks for you help, thoughts, and pateince.

Jul 9 '07 #5

P: n/a
Hi,

Thank you very much. I am learning a lot I appecrciate the help.

I understadn that the Ubound will give the highest array member. When
I try to update my databse with the multiple records, it is only
updating with one record ( I believe this is becuase of the Ubound
fucntion).

How can I make sure all record get into my db?

Here is my curent code:

Dim MyString, MyArray
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

For i = 0 to UBound(MyArray)
oRS3.Fields("PID")= MyArray(i)
Next

oRS3.Update

Jul 9 '07 #6

P: n/a
bcap wrote:
Hi,

Thank you very much. I am learning a lot I appecrciate the help.

I understadn that the Ubound will give the highest array member. When
I try to update my databse with the multiple records, it is only
updating with one record ( I believe this is becuase of the Ubound
fucntion).

How can I make sure all record get into my db?

Here is my curent code:

Dim MyString, MyArray
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

For i = 0 to UBound(MyArray)
oRS3.Fields("PID")= MyArray(i)
Next

oRS3.Update
Look at what your code is doing.
You are looping through the array, setting the value of the PID field in
the CURRENT record of the recordset to the ith value. No attempt to move
to the next record in the recordset (we don't even have any idea if your
recordset even contains multiple records), no attempt to add a new
record to the recordset ...
Then after the loop is finished, and PID field in the current record
contains the last value of the array, you call the Update method. So of
course, the current record in the database is updated with the last
value in the array.

Going back to your first post I see that you want to add a new record
for each PID. Instead of confusing everone by using the word "update"
(as in "... try to update my databse with the multiple records..."), you
should use the word "insert" or even "append". "Update" implies
modifying existing records.

I always try to discourage people from using recordsets to maintain
data, but since you have started ...

Dim MyString, MyArray
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

For i = 0 to UBound(MyArray)
oRS3.AddNew
oRS3.Fields("MeetingID") = 1
oRS3.Fields("PID")= MyArray(i)
oRS3.Update
Next

Better yet would be to use a sql statement to update your data:

Dim sql, cmd, arParms
sql="Insert Into tablename (MeetingID, PID) values (?,?)"
set cmd=createobject("adodb.command")
cmd.commandtype=1 'adCmdText
cmd.commandtext = sql
set cmd.activeconnection = yourconnectionobject
MyString = request.form("PID")
MyArray = Split(MyString,",") 'the delimiter is the comma

For i = 0 to UBound(MyArray)
arParms=Array(1, MyArray(i))
cmd.Execute ,arParms,128 '128=adExecuteNoRecords
Next
'close and destroy your connection if finished with it
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 9 '07 #7

P: n/a

thank you very much! =-)

Jul 11 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.