Discussion Locked

Inserting multiple values into Access97

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a form for our Intranet that captures and writes information to an Access97 database via a SQL Insert statement. Everything works fine except for the two fields that are populated by drop down lists (which are stored in tables in the same Access database). For every other field multiple values can be entered and they are written to the database correctly, however, from the drop down lists only the first value is written back to the database. How do I get the multiple values in the drop down lists to write to the database correctly? Using an underscore between the values is not an option.

5 replies

by fofa

If you need seperate rows, you will have to loop through and insert for each value, however if you want a string, concantenate the multi-values together in a string.

by dan_cohen

Multiple answers on a drop down box are returned as Answer1, Answer2, Answer3 (a comma between each selected option).

On your html form (I am assuming you are using Active Server Pages) you need to use the Split function to parse the multiple answers such as below:

tempstring = Request.Form("YourListBoxName")

tempArray = split(tempstring,",")
For p=0 To UBound(tempArray)
strAnswer = strAnswer & " " & tempArray(p)
Next

You would then write the string strAnswer to the database.

Hope this helps.

This discussion is closed to new replies.