#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0

    Inserting Duplicate Records


    Hi,
    I have a table called steel_tbl with columns ID(auto number), date pno , dia, grade, heatlot, weight, status.
    I have a form which I use to insert values into this table.


    I have 5 fields on the form. date-textbox, pno-combobox, heatlot-textbox, weight-textbox, bundles-textbox. I have a text box to enter number of bundles. When the user enters 2 bundles I want to create 2 records of the information in the fields. If the user enters 3 bundles I want to insert 3 rows in the table with the same information. Is this possible in MS Access 2000? Any help would be appreciated. Thank you
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    yes, you need an integers table and it's easy

    CREATE TABLE integers
    ( i INTEGER NOT NULL PRIMARY KEY )

    then load it up with integer values from 0 through 9 or whatever

    then

    INSERT INTO yourtable ( yourcolumns )
    SELECT formvalues
    FROM integers WHERE i < form.bundles

    so if the user enters 4 in the bundles box, the INSERT will insert your values 4 times (once for each of the integers 0 through 3)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0
    That's awesome! It works! Thank you so much

IMN logo majestic logo threadwatch logo seochat tools logo