'Dead' fields in the database?

Results 1 to 3 of 3

Thread: 'Dead' fields in the database?

  1. #1
    Jonty Guest

    Default 'Dead' fields in the database?

    I have an HTML form which posts values to and asp page which should insert the record into an Access database. I have written a little &#039;utility&#039; script file which loops round each of the form field values and inserts them into the relevant database fields using syntax something along the lines of:<BR><BR>formVal = Request.Form(formArray(tLoop))<BR>If formVal &#060;&#062; "" Then thisRS(dbArray(tLoop)) = formVal<BR><BR>This seems to work fine, but if I then update a record (at a later time) that has been created in this way with the following code (again looping to update all the fields):<BR><BR>If dbVal &#060;&#062; formVal Then thisRS(dbArray(tLoop)) = formVal<BR><BR>For some reason, it won&#039;t update fields which had no value when the record was created. I don&#039;t get an error message, but if I go back to the record, nothing has changed for these fields. However, there is no point in me validating these fields as they are not required.<BR><BR>The update procedure works fine if a value was entered when the record was created, but appears &#039;dead&#039; otherwise.<BR><BR>Any thoughts?<BR>Thanks<BR><BR>Jonty

  2. #2
    Join Date
    Dec 1969

    Default RE: 'Dead' fields in the database?

    You should have 2 different functions<BR><BR>1 that does the insert and one that does the update<BR><BR>you need to show the actual code

  3. #3
    Jonty Guest

    Default RE: 'Dead' fields in the database?

    There are two different functions. The add function being (without all the connection code):<BR><BR>dbArray = Split(dbFields, ",")<BR>formArray = Split(formFields, ",")<BR>thisRS.AddNew<BR>For tLoop = LBound(dbArray) To UBound(dbArray)<BR>fVal = Request.Form(formArray(tLoop))<BR>If fVal &#060;&#062; "" Then thisRS(dbArray(tLoop)) = fVal<BR>Next<BR><BR>thisRS.Update<BR><BR><BR>The update function is:<BR><BR>dbArray = Split(dbFields, ",")<BR>formArray = Split(formFields, ",")<BR>For tLoop = LBound(dbArray) To UBound(dbArray)<BR>dbVal = thisRS(dbArray(tLoop))<BR>fVal = Request.Form(formArray(tLoop))<BR>If dbVal &#060;&#062; fVal Then thisRS(dbArray(tLoop)) = fVal<BR>Next<BR><BR><BR>The reason behind coding like this is so that it&#039;s as flexible as possible as a function and is just pulled in as an include file into whichever pages I need without any modification to the code.<BR><BR>Any more ideas?

Posting Permissions

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