Results 1 to 6 of 6

Thread: Access data - crosstab?? - Now Resolved

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    48

    Access data - crosstab?? - Now Resolved

    Hi,

    I have a table of data imported from our company's main system.

    The data shows duplicate records that have been assigned new codes.

    i.e.

    Code Surname FirstName Title DOB
    1001 Smith Bob Mr 02/02/1976
    1234 Smith Bob Mr 02/02/1976
    .................
    ...............

    etc

    There are a few thousand of these.

    What I want is the data in the format

    Code1 Code2 Surname FirstName Title DOB
    1001 1234 Smith Bob Mr 02/02/1976

    Any ideas? I am really struggling at the moment

    Cheers

    Mark
    Last edited by Mr_Floyd1976; Jul 19th, 2006 at 08:00 AM. Reason: Resolved

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Access data - crosstab??

    is 2 the maximum number of times they can be duplicated? or could bob smith have ½ dozen records.
    i assume you want to put the data in a new table, but this is unclear to me, or do you just want to put them in a report or printout

    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    48

    Re: Access data - crosstab??

    yes 2 is the maximum, well the most I have found. Could possibly be more.

    Yes, i need the data in a new table

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Access data - crosstab??

    does the table already exist or does it need to be created?

    what code are you using now to access the data?

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    48

    Re: Access data - crosstab??

    Quote Originally Posted by westconn1
    does the table already exist or does it need to be created?

    what code are you using now to access the data?
    Doesn't really matter.. I just want to be able to get the data in the format I require..

    The table is currently sitting in Access and has been extracted using Monarch.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Access data - crosstab??

    VB Code:
    1. Dim rstplant As Recordset, rstplant2 As Recordset, rstdupes As Recordset
    2.     Set rstplant = dbsplant.OpenRecordset("plant_details", dbOpenDynaset)
    3.     Set rstplant2 = dbsplant.OpenRecordset("plant_details", dbOpenDynaset)
    4.     Set rstdupes = dbsplant.OpenRecordset("duplicates", dbOpenDynaset)
    5. For i = 0 To rstplant.RecordCount - 1
    6.    
    7.     For j = i - 1 To rstplant2.RecordCount - 1
    8.         If rstplant(2) = rstplant2(2) And rstplant(3) = rstplant2(3) And rstplant(5) = rstplant2(5) Then
    9.               rstdupes.AddNew
    10.                 rstdupes(1) = rstplant(1)
    11.                 rstdupes(2) = rtsplant2(1)
    12.                 rstdupes(3) = rstplant(2)
    13.                 rstdupes(4) = rstplant(3)
    14.                 rstdupes(5) = rstplant(4)
    15.                 rstdupes(6) = rstplant(5)
    16.             rstdupes.Update
    17.             rstplant.MoveFirst
    18.             Exit For
    19.         End If
    20.    
    21.        
    22.         rstplant2.MoveNext
    23.     Next
    24.     rstplant.MoveNext
    25. Next

    this is code to do what you ask, using 2recordsets from your table and a second table of dupicates to add to, you will have to change this to reference your tables.

    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width