Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Crostab to New table


Message #1 by "Y SILINE" <y.siline@u...> on Mon, 26 Mar 2001 02:48:04
Hey!

I need help from you all now, what I want to do is using a string of sql 

to select some information in form of crostab query and put it into a new 

table directly.



wait for your help.
Message #2 by "John Ruff" <papparuff@c...> on Mon, 26 Mar 2001 07:33:22 -0800
You will need to create a procedure to do it.  Try This



Using Access 97

Public Sub NewTable97()

    ' Access 97

    ' Populate a table with data from a crosstab query

    

    Dim rstQuery As Recordset

    Dim rstNewTable As Recordset

    

    Set rstQuery = CurrentDb.OpenRecordset("qry_CrossTabQuery")

    Set rstNewTable = CurrentDb.OpenRecordset("tbl_NewTable")

    

    Do While Not rstQuery.EOF

        rstNewTable.AddNew

            rstNewTable!Field1 = rstQuery!Field1

            rstNewTable!Field2 = rstQuery!Field2

        rstNewTable.Update

        rstQuery.MoveNext

    Loop



    rstQuery.Close

    rstNewTable.Close

    Set rstQuery = Nothing

    Set rstNewTable = Nothing

    

End Sub



Using Access 2000

Public Sub NewTable2000()

    ' Access 2000

    ' Insure there is a reference to Microsoft DAO x.xx Object Library

    ' Populate a table with data from a crosstab query

     

    Dim rstQuery As DAO.Recordset

    Dim rstNewTable As DAO.Recordset

    

    Set rstQuery = CurrentDb.OpenRecordset("qry_CrossTabQuery")

    Set rstNewTable = CurrentDb.OpenRecordset("tbl_NewTable")

    

    Do While Not rstQuery.EOF

        rstNewTable.AddNew

            rstNewTable!Field1 = rstQuery!Field1

            rstNewTable!Field2 = rstQuery!Field2

        rstNewTable.Update

        rstQuery.MoveNext

    Loop



    rstQuery.Close

    rstNewTable.Close

    Set rstQuery = Nothing

    Set rstNewTable = Nothing



End Sub



John Ruff - The Eternal Optimist :)

 -----Original Message-----

From: 	Y SILINE [mailto:y.siline@u...] 

Sent:	Monday, March 26, 2001 2:48 AM

To:	Access

Subject:	[access] Crostab to New table



Hey!

I need help from you all now, what I want to do is using a string of sql 

to select some information in form of crostab query and put it into a new 

table directly.



wait for your help.








  Return to Index