I have two combo box and their source is the same table
ComboBox 1
Control Source = PartNo
Row Source =
SELECT Parts.PartsId, Parts.PartNumber, Parts.Description
FROM Parts
WHERE (((Parts.PartNumber)<>" "))
ORDER BY Parts.PartNumber;
ComboBox 2
ComboBox 1
Control Source = Description
Row Source =
SELECT Parts.PartsId, Parts.PartNumber, Parts.Description
FROM Parts
WHERE (((Parts.Description)<>" "))
ORDER BY Parts.Description;
After Update event on Description
After Update on PartNo
I want the user to be able to put the part no in and it will also populate the description field. They can also select the description and it will populate the corresponding PartNo field
When I select the Description and action the after Update event the corresponding PartNo is not going into the PartNumberCbo field
Any help would be greatly appreciated
ComboBox 1
Control Source = PartNo
Row Source =
SELECT Parts.PartsId, Parts.PartNumber, Parts.Description
FROM Parts
WHERE (((Parts.PartNumber)<>" "))
ORDER BY Parts.PartNumber;
ComboBox 2
ComboBox 1
Control Source = Description
Row Source =
SELECT Parts.PartsId, Parts.PartNumber, Parts.Description
FROM Parts
WHERE (((Parts.Description)<>" "))
ORDER BY Parts.Description;
After Update event on Description
Code:
Private Sub DescriptionCbo_AfterUpdate()
If Len(Me.PartNo & vbNullString) = 0 Then
Me.PartNumberCbo = " "
End If
If Len(Me.DescriptionCbo.Column(2) & vbNullString) > 0 Then
Me.PartNumberCbo = Me.DescriptionCbo.Column(1)
Me.ValidOrdFld = 1
Else
MsgBox "Please enter a Description"
Me.DescriptionCbo.SetFocus
End If
If Len(Me.QuantityFld & vbNullString) = 0 Then
MsgBox "Please enter a quantity"
Me.QuantityFld.SetFocus
Exit Sub
End If
End Sub
After Update on PartNo
Code:
Private Sub PartNumberCbo_AfterUpdate()
If Len(Me.PartNumberCbo.Column(1) & vbNullString) = 0 Then
Dim LResponse As Integer
LResponse = MsgBox(" Do you want to leave the Part No blank?", vbYesNo, "Continue")
If LResponse = vbYes Then
' OK Leave it blank
Me.OrderNoFld = Forms![OrdersFrm]![OrderNoFld]
Exit Sub
Else
Me.PartNumberCbo.SetFocus
End If
Else
Me.ValidOrdFld = 1
' If the part number has been selected and ther description = Null then move the desciption into the description field - no
Me.DescriptionCbo = DLookup("Description", "Parts", "[PartsId] = " & Me.PartNumberCbo.Column(0))
End If
Me.OrderNoFld = Forms![OrdersFrm]![OrderNoFld]
End Sub
I want the user to be able to put the part no in and it will also populate the description field. They can also select the description and it will populate the corresponding PartNo field
When I select the Description and action the after Update event the corresponding PartNo is not going into the PartNumberCbo field
Any help would be greatly appreciated