Results 1 to 3 of 3

Thread: How do I

  1. #1
    Join Date
    Sep 2006
    Posts
    34

    Unanswered: How do I

    How do I insert multiply records into a table using vba ?
    eg. insert orderlines into order table where order_id = something

    and then repeat this untill all records added

    hope this makes sense

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Untested, but you get the idea:
    Code:
    Dim Counter as long
    Counter = yournumberofrecordshere
    
    Dim dbs As DAO.Database
    Set dbs = CurrentDb
    Dim rstTable As DAO.Recordset
    Set rstTable = dbs.OpenRecordset("YourTableNameHere", dbOpenDynaset)
    With rstTable
    While Counter > 0
        .AddNew
        !FldName = whatever
        .Update
    Wend
    End With
    Just create a conditional if statement in there as well based on your criteria.
    Last edited by nckdryr; 01-22-07 at 13:51.
    Me.Geek = True

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Air code:
    Code:
    Dim s as string
     
    s = "INSERT INTO MyTable SELECT Col1, Col2 FROM MyOtherTable WHERE MyConditionCol = 'MyCondition'"
     
    CurrentDb.Execute s
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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