Question : Vlookup as MsAccess Query - possible? But with one variance...

Hi Experts,

This one has been tough for me.  I have explored the possibilities with the Query Design (MsAccess 2007) and can't get around this problem (or I'm running around in circles).  Here the Problem:

I have one Table with 105.000 Records.  Each line represents a PartNumber to assemble a Bicycle and the Quantity that was used and the Document to take stuff out of Inventory.  Like this:

ColumnNames:            PartNumber             Quantity               DeliveryNoteNumber
Sample Record:           100KXyz333             20                        8999

I want to Group these by Bicycle Model.  Problem is: This particular Table (called: PartNumbers) does not have this Reference.  I have these in another Table.  Called: PartReferences.  The Structure here is:

ColumnNames:              PartNumber            BicycleModel
Sample Record:             100KXyz333            A
                                      800KXyz333            B
                                      340uuuTTT4            C
                                      300IT5555O            D

Now this would be easy in Excel.  I just do a VLOOKUP and pull the "BicycleModel" Value into the First Table.  I can do this with a simple Query and combine both columns PartNumber <=> PartNumber.  BUT.  I have one Problem with the Second Table!  (Here is the Twist! You didn't think this was easy, ... ;-)  There are PartNumbers that are common between Models (means DUPES)  PartNumber 800KXyz333 appears 3 times for 3 different Models.

To solve this I have a Third Table where the People from the Shipping Department registered: DeliveryNoteNumber,  PartNumber, Quantity, BicycleModel.

Now I can hinge the first Table to this Third Table by: DeliveryNoteNumber <=> DeliveryNoteNumber and Pull the BicycleModel to the First Table.  But the Problem here is that among the DeliveryNoteNumbers are several Models that have gone out.  Like this:
ShippingTable:
ColumnNames:                  PartNumber                  Quantity             BicycleModel           DeliveryNoteNumber
Sample Records:               100KXyz333                  10                       A                            8999
                                          800KXyz333                 15                        B                            8999
                                          340uuuTTT4                  8                         C                            9002
                                          300IT5555O                  3                         D                            9003

My last Thought was to have this in Code - here my PseudoCode:
FirstTable has a Column called MODEL
Code starts.
Reads First Record (PartNumber) > What is it?  Look-up at ReferenceTable.  Found it! Take Model and write it in Column MODEL
Next Record > Repeat Procedure.  Now ReferenceTable has Same PartNumber Twice for two Models
Now Go to ShippingTable and Lookup DeliveryNoteNumber.  Count BicycleModel (if A appears 20 times and B only 3 times, then this DeliveryNoteNumber was used for a "A"-Model.  The 3 B-Model Parts are common to both Models, and this time have been used to
assemble the A-Model.  Assume this was a A-Model and pull this Value over to the Record being considered at FirstTable.
Next Record
Until all 105.000 Records have been considered/evaluated.
Finish.

Is this possible? Or too complicated?  What do you think?

Thanks a 105.000 times ;-)

MC

Answer : Vlookup as MsAccess Query - possible? But with one variance...

<>

 I don't think you would.

As I said, I'd start off by eliminating the easy ones first, so first consturct a group by query which returns the number of models for each part.  

Add your inventory and shippment table and join on the  DeliveryNoteNumber.  Now change it to a group by, pull down part from the inventory table, group on that, then pull down the model field from shipping and make that the count. Pull down the model number a second time and set it to last or first.   Save the query.

Now start a new query with the inventory table.  Add the query you just saved and join the two on the part number.  Pull down the count and put a criteria check on it of = 1.    Change the query to an update and use the model number to update the model number field in the inventory table.

Now see what's left.

JimD.

Random Solutions  
 
programming4us programming4us