Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    79

    Unanswered: Insert Into into same record

    I am performing a do until and am trying to update 2 fields on 1 record (the original program has more). Even when trying to add a rs.movefirst on the second loop, it still inserts data on the next record. How can I run both of my loops and add data on the same record?

    Do Until NumberOfCharacters = 3
    'Produces a random number based on an array of 36
    RndNum = Int(Rnd * 36)
    'Generates a continuous listing
    'PhoenicList = PhoenicList + strWordListArray(RndNum) + " "
    CharacterList = CharacterList + strCharacterListArray(RndNum) + " "
    'Label1.Caption = PhoenicList
    Label2.Caption = CharacterList
    'Print results to text files
    intCharacter = strCharacterListArray(RndNum)
    STRSELECT = "INSERT into tblCharacter (Character1) values (" & "'" & CharacterList & "'" & ")"
    NumberOfCharacters = NumberOfCharacters + 1
    'intCharacterCount = intCharacter + 1
    strCharacter = strCharacter & intCharacterCount
    Loop
    db.Execute STRSELECT

    NumberOfCharacters = 0
    PhoenicList = ""
    CharacterList = ""
    Do Until NumberOfCharacters = 3
    'Produces a random number based on an array of 36
    RndNum = Int(Rnd * 36)
    'Generates a continuous listing
    'PhoenicList = PhoenicList + strWordListArray(RndNum) + " "
    CharacterList = CharacterList + strCharacterListArray(RndNum) + " "
    'Label1.Caption = PhoenicList
    Label2.Caption = CharacterList
    'Print results to text files
    intCharacter = strCharacterListArray(RndNum)
    STRSELECT = "INSERT into tblCharacter (Character2) values (" & "'" & CharacterList & "'" & ")"
    NumberOfCharacters = NumberOfCharacters + 1
    'intCharacterCount = intCharacter + 1
    strCharacter = strCharacter & intCharacterCount
    Loop
    db.Execute STRSELECT
    Last edited by miracleblake; 01-29-08 at 10:59. Reason: Fix

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    If you are trying to update a record, why then are you using INSERT INTO instead of UPDATE?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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