Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Red face Unanswered: Updating an access database with linked tables (in Fronpage)

    Hi there,

    I have two tables in an 'library'access db - one is a books table and the other is a categories table. I have managed to create an input form in Frontpage allowing the user to add a new book and select the category that it belongs in from a dropdown (join to the categories table). The problem is when I try to update a record - I cannot get the dropdown categories list to keep the record value, it just defaults to the top of the list. Does anyone have any idea how to do this - its driving me crazy.

    Thanx in advance

    Mannix

  2. #2
    Join Date
    Oct 2003
    Posts
    2

    Cool Re: Updating an access database with linked tables (in Fronpage)

    Originally posted by mannix
    Hi there,

    I have two tables in an 'library'access db - one is a books table and the other is a categories table. I have managed to create an input form in Frontpage allowing the user to add a new book and select the category that it belongs in from a dropdown (join to the categories table). The problem is when I try to update a record - I cannot get the dropdown categories list to keep the record value, it just defaults to the top of the list. Does anyone have any idea how to do this - its driving me crazy.

    Thanx in advance

    Mannix
    Okay. You need to follow this process (assuming asp page).

    1. On page load, determine if this is for a new record or existing

    2. If its an existing book then read the data into an array where you know which element contains the category id. This happens before the form is created (remember that asp is processed as the page loads).

    3. For a new book set the options with " selected = true " for the first option. For an existing book then look up the category (look in the array in step 2) and when this is the same category then place "selected = true " on the option.

    Code


    Assumes you have loaded the CategoryID in the BookArray(2) element.

    Recordset.MoveFirst
    Response.Write("<select name = 'CategoryPicker'>")

    While not Recordset.EOF

    if BookArray(2) = CategoryRecordset("CategoryID") then
    Repsonse.Write("<option selected = true> " & CategoryRecordset("CategoryID") & "</option>"
    else
    Repsonse.Write("<option> " + CategoryRecordset("CategoryID") + "</option>"
    end if

    CategoryRecordset.MoveNext

    end while
    Repsponse.Write("</select>")


    Hope this helps a bit and do mind the dodgy VB (Javascript geek is me).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •