I have the following code in a not in list event and when it opens the form Add_New_Part, it opens the form to the first record and overwrites the first Part Number record. I want it to open to a blank record to add a new one, not change an existing one. Other than this problem, this code is doing exactly what I want it to do. Oh, and I am opening the form with the field cboPartNumber in add mode - it is actually a subform. Can somebody tell me what I need to do?
Private Sub cboPartNumber_NotInList(newdata As String, Response As Integer)
Response = acDataErrContinue
Call PartNumber_Not_Found(newdata)
End Sub
Public Sub PartNumber_Not_Found(newdata)
Dim ans As Variant
' new part
gbl_exit_name = False
ans = MsgBox("Do you want to add this part?", _
vbYesNo, "Add New part?")
If ans = vbNo Then
Me.cboPartNumber = Null
DoCmd.GoToControl "cboPartNumber"
GoTo exit_it
End If
' add part
DoCmd.OpenForm ("Add_New_Part")
Form_Add_New_Part.PartNumber = newdata
Me.cboPartNumber = Null
DoCmd.GoToControl "PartNumber"
exit_it:
End Sub
Thanks!!
Lara
Private Sub cboPartNumber_NotInList(newdata As String, Response As Integer)
Response = acDataErrContinue
Call PartNumber_Not_Found(newdata)
End Sub
Public Sub PartNumber_Not_Found(newdata)
Dim ans As Variant
' new part
gbl_exit_name = False
ans = MsgBox("Do you want to add this part?", _
vbYesNo, "Add New part?")
If ans = vbNo Then
Me.cboPartNumber = Null
DoCmd.GoToControl "cboPartNumber"
GoTo exit_it
End If
' add part
DoCmd.OpenForm ("Add_New_Part")
Form_Add_New_Part.PartNumber = newdata
Me.cboPartNumber = Null
DoCmd.GoToControl "PartNumber"
exit_it:
End Sub
Thanks!!
Lara