• Matching values (2000/XP)

    Author
    Topic
    #431246

    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
    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1009073

      Do you want to write the results for c) to a different field than those for a)? If not, you might skip a) and and perform only c) and d).

      • #1009076

        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.

        • #1009081

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

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

          • #1009087

            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. clapping

    Viewing 0 reply threads
    Reply To: Matching values (2000/XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: