Trying to use AddNew with a form field.

Results 1 to 3 of 3

Thread: Trying to use AddNew with a form field.

  1. #1
    Bob Perini Guest

    Default Trying to use AddNew with a form field.

    I was trying to dynamically create the array for the AddNew Function, I&#039ve tried quite a few different things but none of them seem to work. I do not want to type in the fields for each value coming from the form(the rs("Item")="blah" thing). If anyone has done this before let me know.<BR>Here is the code I currently have--<BR><BR>rs is the recordset.<BR>&#039Read in the information from a form<BR>For Each Item in Request.Form<BR> if Item &#060;&#062; "submit" then<BR> NameArray(j)=Item<BR> NameArray(j) = Replace (NameArray(j),"&#039","&#039&#039")<BR> ValueArray(j)=Request.Form(Item)<BR> ValueArray(j) = Replace (ValueArray(j),"&#039","&#039&#039")<BR> j=j+1<BR> end if<BR>Next<BR>&#039Insert the information from the form into the database<BR>rs.AddNew NameArray,ValueArray<BR><BR>Thanks,<BR>--<BR>Bob

  2. #2
    Joel M Guest

    Default What's the difference

    what&#039s the difference... you&#039d end up typing more the way you&#039re trying to do it... you could just use the with statment and shorten your typing:<BR>-----------<BR><BR>with rs<BR><BR>.addnew<BR>.fields("blah") = someValue<BR>.update<BR><BR>end with<BR>-------------<BR>and so forth<BR><BR>there&#039s no difference between typing :<BR><BR>someLongArrayName(j) = someValue<BR><BR>and typing:<BR><BR>.fields("blah") = someValue<BR><BR><BR>hope it helps<BR>Joel M

  3. #3
    Join Date
    Dec 1969

    Default RE: What's the difference

    It does make a difference, I don&#039t want to type all 35 field names, I was trying to make the function generic, for use with all of my programs....

Posting Permissions

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