Results 1 to 2 of 2

Thread: Symbolic sub for Field name assgnment for recordsets

  1. #1
    Guest

    Post

    I'm trying to make an update to record set and update field names day01, day02, day03, day04...

    I would like to perform this update by a for loop and then use recordsetname.day & itr = value... for the each iteration of the for loop...

    kind of like this...

    for i = 1 to countdays
    recordset.edit
    recordset.day & i = value 'help here
    recordset.update
    next i

    Can anyone help with this pitiful mess?

    Thanks,
    Marc


  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Try this in its place:

    Code:
    for i = 1 to countdays
       SQLstring= "update tablename set day0" & i & "= " & value & " where some_condition = uniquerecord"
       database.execute SQLstring, dbFailOnError
    next i
    note if the value field is character, then the script changes slightly

    Code:
    for i = 1 to countdays
       SQLstring= "update tablename set day0" & i & "= '" & value & "' where some_condition = uniquerecord"
       database.execute SQLstring, dbFailOnError
    next i

Posting Permissions

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



Click Here to Expand Forum to Full Width