#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Ocean State
    Posts
    6
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    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.

    Code:
    Session("SurveyKey") = Recordset.Fields("PrimaryKey")
    That will create a session.

    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
    Code:
    "SELECT * FROM tblSurvey WHERE PrimaryKey = " & session("SurveyKey")
    If there are lots of questions then you might only want to return the fields on the current page. Anyway good luck.

IMN logo majestic logo threadwatch logo seochat tools logo