Results 1 to 3 of 3

Thread: ADD new fields from a loop

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    ADD new fields from a loop

    I just have a table1 into c:\mydir\mymbd.mdb
    I just have 3 fields (field1, field2..)
    I need, from the loop in code, to add new fields based the var TEST

    Code:
        RIGA = 0
        While Not GAF_RS.EOF
        TEST = GAF_RS(0)
        RIGA = RIGA + 1
        GAF_RS.MoveNext
        Wend
    note:
    all fields are TEXT format and max character from var TEST is max 2

    please with vb6 code, tks.
    possible?
    Last edited by luca90; Sep 29th, 2010 at 06:23 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ADD new fields from a loop

    Modify to fit your needs
    Code:
    Dim sSQL As String
        RIGA = 0
        While Not GAF_RS.EOF
        TEST = GAF_RS(0)
        sSQL = "ALTER TABLE table1 ADD " & Test & " Text(2) "
        YourConnectionObject.Execute sSQL
        RIGA = RIGA + 1
        GAF_RS.MoveNext
        Wend

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: ADD new fields from a loop

    Quote Originally Posted by hack View Post
    modify to fit your needs
    Code:
    dim ssql as string
        riga = 0
        while not gaf_rs.eof
        test = gaf_rs(0)
        ssql = "alter table table1 add " & test & " text(2) "
        yourconnectionobject.execute ssql
        riga = riga + 1
        gaf_rs.movenext
        wend
    excelletnt!

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