Results 1 to 2 of 2
  1. #1
    askjacq is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    11

    add multiple records to a table

    Don't know if an append query is the way to go here or if it's possible to do this in a macro or in a sql query.



    I want to create a procedure that will append to a table the number of records specified in another table.

    Example:

    table called tDaily
    Fields: DID (autonumber primary key), qtymfg (number)

    table called tSNs
    Fields: ID (autonumber), DID (lookup to tDaily DID), SN

    When I run the procedure, I want it to add to tSNs table the number of records specified in the qtymfg field of the active record. I want the DID to be the DID of the active record. I want the SN to be the SN of the last record in the tSN table +1 and then numbered in increments.

    Example:

    tDaily record: DID - 99; qtymfg - 3
    Last SN of the tSN table - 1001

    Run the procedure and 3 records are added to the tSNs table:

    ID - 4; DID - 99; SN - 1002
    ID - 5; DID - 99; SN - 1003
    ID - 6; DID - 99; SN - 1004

    What is the easiest way to do this?

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Probably need a VBA procedure with looping structure that will append as many records as required and that also increments the SN value. The append can be done by executing an SQL INSERT action or opening a recordset and adding records to the recordset.
    Last edited by June7; 02-17-2013 at 06:04 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 02-08-2013, 07:43 AM
  2. Replies: 4
    Last Post: 10-30-2012, 04:33 PM
  3. Form to add multiple records to table
    By jcarstens in forum Forms
    Replies: 1
    Last Post: 05-17-2012, 06:26 PM
  4. Inserting multiple records into a table
    By New2Access in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 09:18 PM
  5. Referencing multiple records in a table
    By akbigcat86 in forum Programming
    Replies: 14
    Last Post: 07-22-2010, 01:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums