how to insert record from one table to another

  • First table structre (call this table1) looks something like this,

    3 columns

    date, errors, employeeid

    5/27/ 5 5

    5/26/ 32 31

    Second table structure (call this table2) looks something like this

    5 columns

    errorid, errordate, iserror, employeeid, notes

    1 6/23 1 5 'blabla '

    Now here is the task:

    In table1, employeeid 5 made 5 errors on date 5/27, I need to enter the errors in table2 five times for that one date 5/27. Just like I need to enter the 32 errors made by employeeid 31 on 5/26 into table 2 thirty two times. What is the best way to go about this please? Its a tricky one and any help will be appreciated. Thanks

    Note: table1 has over a thousand records

  • Are you entering any values into the Notes column during this process?

  • Not at all, that is left empty

  • Its empty

  • Give the attached code a try. You need the code in both files.

  • Thanks, Ill try both codes and get back to you shortly!

  • I tried both codes and with a little tweaking to fit my environment, it worked perfectly. You are a genius and I appreciate your help. The UDF also showed me how to use the abs function properly. Thanks again for the help!!

  • The UDF is a Dynamic Tally table. Take the time to read the second to last article I reference below in my signature block regarding Tally tables. You will find them extremely useful.

  • Hi,

    You mean,

    At Table1

    Insert into Table1(empID,ErrorCount,ErrorDate) Values(1,5,'27-05-2009')

    At Table2

    5 new rows for empID 1

    eg.

    Insert Into Table2(ErrorID,ErrorDate,IsError,EmpID,Notes) Values

    (1,'27-05-2009',1,1,'error 1')

    Insert Into Table2(ErrorID,ErrorDate,IsError,EmpID,Notes) Values

    (2,'27-05-2009',1,1,'error 2')

    Insert Into Table2(ErrorID,ErrorDate,IsError,EmpID,Notes) Values

    (3,'27-05-2009',1,1,'error 3')

    Insert Into Table2(ErrorID,ErrorDate,IsError,EmpID,Notes) Values

    (4,'27-05-2009',1,1,'error 4')

    Insert Into Table2(ErrorID,ErrorDate,IsError,EmpID,Notes) Values

    (5,'27-05-2009',1,1,'error 5')

    Did you this type of functionality??

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply