Copy data into another table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • colleen1980@gmail.com

    Copy data into another table

    Hi:
    Can any one please help me when user select 2 dates from DDLDate1
    10/09/2006 and DDLDate2 10/12/06 and the name and it close the form. I
    need to create multiple records in the another table on the basis of
    two dates like that.

    Data in continous form table1
    -----------------------------
    Data entered in continous form
    10/09/2006 10/12/2006 John
    10/12/2006 10/13/2006 Petty
    11/11/2006 11/11/2006 Stiffny

    Required data into table table2
    10/09/2006 10/09/06 John
    10/10/06 10/10/06 John
    10/11/06 10/11/06 John
    10/12/06 10/12/06 John
    10/13/06 10/13/06 John
    10/12/2006 10/12/2006 Petty
    10/13/2006 10/13/2006 Petty
    11/11/2006 11/11/2006 Stiffny

    I am currently using a continuous form where there are two drop downs
    one for AppDate and other for EndDate. I need a script here once use
    close the form, Script check the data and create multiple records on
    the basis of date selection into table2. I am using two tables. One for
    the continous form and the other for the reports (Both have same
    fields). Continous form table i empty it every time once it close. So i
    need the result into another table assume form table name is table1 and
    table where i need multiple records name is table2.

    Thanks.

  • Kc-Mass

    #2
    Re: Copy data into another table

    You could:

    Assuming table2 is filled from form controls
    Assuming fields of StartDate, EndDate, Name in table2
    'Pass the values of your fields to a procedure like this.

    Sub FillTable2(dtSt art, dtEnd, strName)
    Dim DB As database
    Dim rs2 As Recordset
    Dim dtMark As Date
    Set DB = CurrentDb
    Set rs2 = DB.openrecordse t("Students", dbopendynaset)
    rs2.MoveLast
    For stMark = dtStart To dtEnd
    rs2.AddNew
    rs2.StartDate = dtMark
    rs2.EndDate = dtMark
    rs2.Name = strName
    rs2.Update
    Next
    End Sub

    I wonder though if there isn't some way to do this with a query.
    PS Why do you want to store a date twice?

    <colleen1980@gm ail.comwrote in message
    news:1160033453 .053577.227400@ b28g2000cwb.goo glegroups.com.. .
    Hi:
    Can any one please help me when user select 2 dates from DDLDate1
    10/09/2006 and DDLDate2 10/12/06 and the name and it close the form. I
    need to create multiple records in the another table on the basis of
    two dates like that.
    >
    Data in continous form table1
    -----------------------------
    Data entered in continous form
    10/09/2006 10/12/2006 John
    10/12/2006 10/13/2006 Petty
    11/11/2006 11/11/2006 Stiffny
    >
    Required data into table table2
    10/09/2006 10/09/06 John
    10/10/06 10/10/06 John
    10/11/06 10/11/06 John
    10/12/06 10/12/06 John
    10/13/06 10/13/06 John
    10/12/2006 10/12/2006 Petty
    10/13/2006 10/13/2006 Petty
    11/11/2006 11/11/2006 Stiffny
    >
    I am currently using a continuous form where there are two drop downs
    one for AppDate and other for EndDate. I need a script here once use
    close the form, Script check the data and create multiple records on
    the basis of date selection into table2. I am using two tables. One for
    the continous form and the other for the reports (Both have same
    fields). Continous form table i empty it every time once it close. So i
    need the result into another table assume form table name is table1 and
    table where i need multiple records name is table2.
    >
    Thanks.
    >

    Comment

    • Kc-Mass

      #3
      Re: Copy data into another table

      The first assumption is that table1 NOT table2 is filled from form.
      "Kc-Mass" <connearney@com cast.netwrote in message
      news:VvydnfAKru 53sbjYnZ2dnUVZ_ sqdnZ2d@comcast .com...
      You could:
      >
      Assuming table2 is filled from form controls
      Assuming fields of StartDate, EndDate, Name in table2
      'Pass the values of your fields to a procedure like this.
      >
      Sub FillTable2(dtSt art, dtEnd, strName)
      Dim DB As database
      Dim rs2 As Recordset
      Dim dtMark As Date
      Set DB = CurrentDb
      Set rs2 = DB.openrecordse t("Students", dbopendynaset)
      rs2.MoveLast
      For stMark = dtStart To dtEnd
      rs2.AddNew
      rs2.StartDate = dtMark
      rs2.EndDate = dtMark
      rs2.Name = strName
      rs2.Update
      Next
      End Sub
      >
      I wonder though if there isn't some way to do this with a query.
      PS Why do you want to store a date twice?
      >
      <colleen1980@gm ail.comwrote in message
      news:1160033453 .053577.227400@ b28g2000cwb.goo glegroups.com.. .
      >Hi:
      >Can any one please help me when user select 2 dates from DDLDate1
      >10/09/2006 and DDLDate2 10/12/06 and the name and it close the form. I
      >need to create multiple records in the another table on the basis of
      >two dates like that.
      >>
      >Data in continous form table1
      >-----------------------------
      >Data entered in continous form
      >10/09/2006 10/12/2006 John
      >10/12/2006 10/13/2006 Petty
      >11/11/2006 11/11/2006 Stiffny
      >>
      >Required data into table table2
      >10/09/2006 10/09/06 John
      >10/10/06 10/10/06 John
      >10/11/06 10/11/06 John
      >10/12/06 10/12/06 John
      >10/13/06 10/13/06 John
      >10/12/2006 10/12/2006 Petty
      >10/13/2006 10/13/2006 Petty
      >11/11/2006 11/11/2006 Stiffny
      >>
      >I am currently using a continuous form where there are two drop downs
      >one for AppDate and other for EndDate. I need a script here once use
      >close the form, Script check the data and create multiple records on
      >the basis of date selection into table2. I am using two tables. One for
      >the continous form and the other for the reports (Both have same
      >fields). Continous form table i empty it every time once it close. So i
      >need the result into another table assume form table name is table1 and
      >table where i need multiple records name is table2.
      >>
      >Thanks.
      >>
      >
      >

      Comment

      • Kc-Mass

        #4
        Re: Copy data into another table

        Correction 2 - The refrence to pass the "value of your fields" should
        obviously be pass the "value of your form controls".
        Sorry - That was a long night
        "Kc-Mass" <connearney@com cast.netwrote in message
        news:p8OdnSBzJr YVsLjYnZ2dnUVZ_ sWdnZ2d@comcast .com...
        The first assumption is that table1 NOT table2 is filled from form.
        "Kc-Mass" <connearney@com cast.netwrote in message
        news:VvydnfAKru 53sbjYnZ2dnUVZ_ sqdnZ2d@comcast .com...
        >You could:
        >>
        >Assuming table2 is filled from form controls
        >Assuming fields of StartDate, EndDate, Name in table2
        >'Pass the values of your fields to a procedure like this.
        >>
        >Sub FillTable2(dtSt art, dtEnd, strName)
        > Dim DB As database
        > Dim rs2 As Recordset
        > Dim dtMark As Date
        > Set DB = CurrentDb
        > Set rs2 = DB.openrecordse t("Students", dbopendynaset)
        > rs2.MoveLast
        > For stMark = dtStart To dtEnd
        > rs2.AddNew
        > rs2.StartDate = dtMark
        > rs2.EndDate = dtMark
        > rs2.Name = strName
        > rs2.Update
        > Next
        >End Sub
        >>
        >I wonder though if there isn't some way to do this with a query.
        >PS Why do you want to store a date twice?
        >>
        ><colleen1980@g mail.comwrote in message
        >news:116003345 3.053577.227400 @b28g2000cwb.go oglegroups.com. ..
        >>Hi:
        >>Can any one please help me when user select 2 dates from DDLDate1
        >>10/09/2006 and DDLDate2 10/12/06 and the name and it close the form. I
        >>need to create multiple records in the another table on the basis of
        >>two dates like that.
        >>>
        >>Data in continous form table1
        >>-----------------------------
        >>Data entered in continous form
        >>10/09/2006 10/12/2006 John
        >>10/12/2006 10/13/2006 Petty
        >>11/11/2006 11/11/2006 Stiffny
        >>>
        >>Required data into table table2
        >>10/09/2006 10/09/06 John
        >>10/10/06 10/10/06 John
        >>10/11/06 10/11/06 John
        >>10/12/06 10/12/06 John
        >>10/13/06 10/13/06 John
        >>10/12/2006 10/12/2006 Petty
        >>10/13/2006 10/13/2006 Petty
        >>11/11/2006 11/11/2006 Stiffny
        >>>
        >>I am currently using a continuous form where there are two drop downs
        >>one for AppDate and other for EndDate. I need a script here once use
        >>close the form, Script check the data and create multiple records on
        >>the basis of date selection into table2. I am using two tables. One for
        >>the continous form and the other for the reports (Both have same
        >>fields). Continous form table i empty it every time once it close. So i
        >>need the result into another table assume form table name is table1 and
        >>table where i need multiple records name is table2.
        >>>
        >>Thanks.
        >>>
        >>
        >>
        >
        >

        Comment

        Working...