I have a Parts table with a PartNumber field and a ModelNumber field. The PartNumber will be unique for each part, while there may be duplicates in the ModelNumber field.
I want the Parts form to show the PartNumbers of all parts with duplicate ModelNumbers in the SameParts textbox.
Here's what I have done so far, but I might be way off...
Can anyone help? :)
CB55
I want the Parts form to show the PartNumbers of all parts with duplicate ModelNumbers in the SameParts textbox.
Here's what I have done so far, but I might be way off...
Code:
Private Sub Form_Current()
Dim s_Matches As String
Dim Rec As DAO.Recordset
Set Rec = CurrentDb.OpenRecordset("SELECT [ModelNumber], [PartNumber] FROM Parts WHERE (((ModelNumber) In (SELECT [ModelNumber] FROM [Parts] As Tmp GROUP BY [ModelNumber] HAVING Count(*)>1 ))) ORDER BY PartNumber;")
If s_Matches = Empty Then
s_Matches = Rec!PartNumber
Else
s_Matches = s_Matches & ", " & Rec!PartNumber
End If
Me.SameParts = s_Matches
s_Matches = Empty
Set Rec = Nothing
End Sub
CB55
Comment