April 1st, 2003, 04:03 PM
Creating session variable
Working on a survey with results going into an Access (2002) database. Each survey-taker would be a new, unique entry in the survey-taker table, and the primary key is set as an autonumber.
The survey is several pages long, and I need a way for the autonumbered primary key to carry over to each page in order to keep the results together. Here is my question:
Would creating a session variable tied to the primary key work, or am I going about this all wrong? If a session variable would work, how do I tie it to an autonumber?
Thanks in advance.
April 3rd, 2003, 03:41 PM
A session variable would work also I'm assuming your using a form so you could also use a hidden field and store the value of the primary key there. Anyway this is how you could use a session.
That will create a session.
Session("SurveyKey") = Recordset.Fields("PrimaryKey")
So what you would do is on the first page you open the recordset and create a new record. Then return the value of the primary key and store in in a session like the code above.
On all that survey pages do a query sorta like
If there are lots of questions then you might only want to return the fields on the current page. Anyway good luck.
"SELECT * FROM tblSurvey WHERE PrimaryKey = " & session("SurveyKey")