Hello,
I have a form (FRM_Inventory_ADD) which adds components to cabinets. If some one enters a Part Number in ComboBox "cboComp" which is not in the list, I am running a "Not In List" event to open another form (FRM_Components_ADD) to create the new item.
Code:
Private Sub cboComp_NotInList(NewData As String, Response As Integer)
Dim Msg As String
Dim CR As String
CR = Chr$(13)
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Ask the user if he or she wishes to create the new partnumber.
Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start FRM_Components_ADD in data entry
' mode as a dialog form, passing the new PartNumber in
' NewData to the OpenForm method's OpenArgs argument. The
' OpenArgs argument is used in Components ADD form's Form_Load event
' procedure.
DoCmd.OpenForm "FRM_Components_ADD", , , , acAdd, acDialog, NewData
End If
End Sub
When FRM_Components_ADD opens, this runs On Load to enter the new part number automatically:
Code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
' If form's OpenArgs property has a value, assign the contents
' of OpenArgs to the PartNumber field. OpenArgs will contain
' a PartNumber if this form is opened using the OpenForm
' method with an OpenArgs argument.
Me![PartNumber] = Me.OpenArgs
End If
End Sub
Everything works great EXCEPT when I close "FRM_Component_ADD" and go back to the original form. How do I clear the ComboBox "cboComp" and then Refresh the form and then have the new Part Number already selected in "cboComp"?
I tried:
Code:
PropertySet [cboComp] = Null
to clear the ComboBox, but i get errors.
Any ideas?
Thank you!