Part is pulling in the description of the part number and not the actual part number.
Also if the part number required does not already exist, part number combo should allow a new part number to be entered and saved as part of the tblQuality.
The part combo box in Peter's amended form is bound the the PartNumberID column, but is set up to show the description. If you want it to show the part number then the AfterUpdate event procedure of the customer combo box would be amended as follows:
Code:
Private Sub cboCustomer_AfterUpdate()
Me.PartNumberID = Null
Me.PartNumberID.RowSource = "SELECT PartnumberID, PartNumber FROM CableParts WHERE CustomerID = " & Me.cboCustomer & " ORDER BY PartNumber"
End Sub
To insert a new row into the CableParts when a new part number value is entered into the combo box, firstly you'd need a form bound to CableParts (frmCableParts in the example below), and the code for the combo box's NotInList event procedure would be as follows:
Code:
Dim ctrl As Control
Dim strMessage As String
Set ctrl = Me.ActiveControl
strMessage = "Add " & NewData & " to list?"
If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
DoCmd.OpenForm "frmCableParts", _
DataMode:=acFormAdd, _
WindowMode:=acDialog, _
OpenArgs:=NewData
' ensure frmCableParts closed
DoCmd.Close acForm, "frmCableParts"
' ensure part has been added
If Not IsNull(Dlookup("PartNumberID", "CableParts", "PartNumber = """ & _
NewData & """")) Then
Response = acDataErrAdded
Else
strMessage = NewData & " was not added to CableParts table."
MsgBox strMessage, vbInformation, "Warning"
Response = acDataErrContinue
ctrl.Undo
End If
Else
Response = acDataErrContinue
ctrl.Undo
End If
In the Open event procedure of frmCableParts you'd put the following code to assign the new part number you entered into the combo box to the PartNumber control's DefaultValue property:
Code:
If Not IsNull(Me.OpenArgs) Then
Me.PartNumber.DefaultValue = """" & Me.OpenArgs & """"
End If
You could of course use your frmAddNewParts form in place of frmCableParts if you only want to insert the limited data.
Note that before you can insert a row for the new part number into tblQuality you must insert a row into the CableParts table. Otherwise referential integrity would be violated. You could extend my code above to execute an INSERT INTO statement to do this, or the code could open another bound form, passing the new part number into it as its OpenArgs property.