Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Matching values (2000/XP)

    Sorry for the unhelpful title, what I need to do is this:

    Compare 2 tables based on a match/join of 4 fields then write the value from the ID field to a field in the first table. The data must be written permanently to table 1, viewing a select query isn't an acceptible option.

    The 'join' fields are actually XY coordinates, stored as doubles.

    a) Some records may find only 1 'match' - Copy the ID value (a long number) from table 2 into a field in table 1
    [img]/forums/images/smilies/cool.gif[/img] Some records may find >1 match - Create a comma separate string of the IDs and write them to a different field in table 1
    c) As 'a' but with the coordinates round to whole numbers
    d) As 'b' but with the coordinates round to whole numbers

    Currently, I'm looping through table 1, passing the coordinates as variables (together with an empty ID variable)to a function. The function loops through table 2 until it find the first match, then I use the now set ID variable.

    I'm a bit stuck on how to handle possible multiple matches 'b' and wondering whether to pass an array/collection to the function and then retrieve it's contents in the main routine.

    I'm a a bit worried about speed as effectively each time I move to another record in table 1 I have to search every record in table 2.

    Any ideas?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Matching values (2000/XP)

    Do you want to write the results for c) to a different field than those for a)? If not, you might skip a) and [img]/forums/images/smilies/cool.gif[/img] and perform only c) and d).

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Matching values (2000/XP)

    Yes, it is being seeing as a two phase type of thing. The 'rounding' of the coordinates produces more 'possible' matches. I need to keep those that were 'exact' separate.

    I'm sure trying to 'round' the values and compare them will take ages but I'm kinda stuck before even before I get to that bit. I really can't think of the most appropriate way to deal with 'a' and 'b'.

    If I deal with 'a' first then the numbers of records needing the lengthier 'b' search would be less BUT it doesn't seem unreasonable to just leap into 'b' and deal with the results of the function differently. ie. if collection.array has one item, write to field a, if it has more than one, loop and create a string and write to field b.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Matching values (2000/XP)

    You could use a series of update queries. See the attached demo.

    The multiple match queries use the Concat function from <post#=301393>post 301393</post#>. It requires a reference to the Microsoft DAO 3.6 Object Library.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Matching values (2000/XP)

    Had just decided to go for a series of update queries but was wondering about the concatenation.

    Your cut down example makes it very clear. Thankyou. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

Posting Permissions

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