0

I have a table of questions for a survey, each one with its identifying number. I have a form that populates with all the questions (this is not an exact number, as more can be added) but I need to store the results into one field, using arrays, because the number of columns for a table holding the results would need to change otherwise whenever a new question is added). I have never worked with arrays but I was told this was the way to do it. I need to store the yes or no answer for a question with its number identifying the question. I also need to know how do I pull it back when I need to display the results of a particular survey, as I would need to link the number of the question to the questions table to display the actual question, and then get the answer and display it too. I have no idea where to start.
My questions table(TA_Questions) has three fields: CategoryID, QuestionID, Question and the table that holds the results(TA_Surveys) has 3 fields: EventId, UserId, Answers(this is where I need to store all the answers to the survey which can be yes,no, or blank). So far there are 29 questions in the survey. In order to display the results I need to access the questions table to get the question using the QuestionID which ideally was stored with its answer in the answers field. Can anybody help me with this code?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by pinkiguana
0

I think I need to simplify, I need sample code arrays to submit all the values of the radiobuttons which each group of Yes/No values is linked to a question Id, and store into one field in my database as a string (I am assuming this requires an array) and how to retrieve these linking the question Id to the question description to be able to display the submitted survey with the chosen answers that would exist in that field as paired values with its identifying Id. Any help will be greatly appreciated!

0

It will be simple if there is always the same number of answers and in the same order, otherwise you will have problems with the position of the answers in the array.

To add the data to the array try:

strQ1 - Request("1")
strQ2 - Request("2")
strQ3 - Request("3")
strQ4 - Request("4")

strBuildArray = strQ1 & "," & strQ2 & "," & strQ3 & "," & strQ4

To get the data back from the array try:

strRecordArray = Split(strRecord, ",")
strA1 = strRecordArray(0)
strA2 = strRecordArray(1)
strA3 = strRecordArray(2)
strA3 = strRecordArray(3)

0

thank you for the reply. Actually, the questions populate from a table, and they have an id which is sorted in ascending, but the number of questions is not always the same as more questions could be added, some deactivated. I will try to see if I can follow what you have illustrated here for what I need.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.