raziel3
Registered User.
- Local time
- Today, 15:54
- Joined
- Oct 5, 2017
- Messages
- 316
I know how to open "another" form to add the record if it is not-in-the-list of a combo box but how do I move to a new record on the SAME from that has the combo box.
I have a combo box that selects existing items and once selected it loads the form with all the details but if the item is not-in-the-list, I want to be able to go to a new record and take the unlisted item from the combo box and place it in one of the detail fields. This is what I have so far but, the form is not moving to the new record. It is moving to the record once it's on the list though.
I have a combo box that selects existing items and once selected it loads the form with all the details but if the item is not-in-the-list, I want to be able to go to a new record and take the unlisted item from the combo box and place it in one of the detail fields. This is what I have so far but, the form is not moving to the new record. It is moving to the record once it's on the list though.
Code:
Private Sub cboSBN_AfterUpdate()
Dim UPPNAME As String
Dim strINAME As String
Dim Answer As Integer
If DCount("*", "Product", "ITEMNAME = '" & Me.cboSBN & "'") <> 0 Then
Answer = MsgBox("Product already exist. View?", vbYesNo, "Duplicate Record!!")
If Answer = vbYes Then
UPPNAME = Me.cboSBN
strINAME = "INAME='" & Me.cboSBN & "'"
Me.Recordset.FindFirst strINAME
ElseIf DCount("*", "Product", "ITEMNAME = '" & Me.cboSBN) & "'" = 0 Then
DoCmd.GoToRecord , , acNewRec
Me.cboSBN = Me.ITEMNAME <---Detail field #1
Me.txtTestUPC = Me.UPC <----Detail Field #2
End If
End If
End Sub