Parts and Models List (1 Viewer)

I still do not really understand what you start with and how you get to the CSV. But I will assume somehow you get a weird CSV in this format with Models in the first row and parts below it.
import.PNG


If you can preprocess outside the database into the correct format it would easier. It should look like this.

modelParts.PNG


I did it in code. This normalize the CSV.

Code:
Public Sub FillModelParts()
  Const ImportTable = "models_Parts_Example"
  Const tableName = "tblModelParts"
  Const PartField = "PartNumber"
  Const ModelField = "ModelNumber"
 
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  Dim PartNumber As String
  Dim modelNumber As String
  Dim strSql As String
 
 
 
  Set rs = CurrentDb.OpenRecordset(ImportTable, dbOpenDynaset)
   For Each fld In rs.Fields
  Do While Not rs.EOF
         Debug.Print rs.AbsolutePosition
         If rs.AbsolutePosition = 0 Then
           modelNumber = fld.Value
         Else
            If Not IsNull(fld.Value) Then
              PartNumber = fld.Value
              strSql = "insert into " & tableName & " (" & ModelField & ", " & PartField & ") values ('" & modelNumber & "', '" & PartNumber & "')"
              Debug.Print strSql
              CurrentDb.Execute strSql
            End If
         End If
      
      
      rs.MoveNext
    Loop
    rs.MoveFirst
   Next fld
End Sub

Now you can do any query you want.
I can group by part and count how many model that part is in.
counts.PNG


I can query to see which models have two specific parts. These models have both parts in the query.

countin.PNG
 
This is simply how I organize it in a spreadsheet for other uses. Mostly just copy and paste.

I will do things like removing duplicates or finding common model numbers across the part
 
I provided the answer. Simply build the junction table I showed and you are done.
 

Users who are viewing this thread

Back
Top Bottom