Add code to not in list event

I have this code in a not in list event of a combobox.

Private Sub cboType_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboType_NotInList

    Dim intAnswer As Integer
    Dim strSQL As String
    
    intAnswer = MsgBox(NewData & " is not in the list. Would you like to add it?", vbQuestion + vbYesNo, "Description")

    If intAnswer = vbYes Then
        strSQL = "INSERT INTO tblTypesLU([Description]) " & "VALUES ('" & NewData & "');"
        CurrentDb.Execute strSQL, dbSeeChanges
        Response = acDataErrAdded
    End If

Exit_cboType_NotInList:
    Exit Sub

Err_cboType_NotInList:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
    Resume Exit_cboType_NotInList

End Sub

Open in new window


But I want to add the DetailID from the form to the syntax.

So if the table looks like this prior to the code:

RecordID         Description          DetailID
1                       Something  
2                       Something Else

Have it look like this after the code runs:

RecordID         Description          DetailID
1                       Something               47
2                       Something Else       47

How would I change the on not in list event?
SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
The simple answer is to modify the insert to add the second field but in reality, I have no clue what you are trying to do.  What would the purpose of adding the ID of the first record to which the lookup value was attached to the lookup table?
0
John TsioumprisSoftware & Systems EngineerCommented:
strSQL = "INSERT INTO tblTypesLU([Description],[DetailID]) " & "VALUES ('" & NewData & "','" & Me.DetailID &"'");"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
Pat, the purposes it to add the ID so that further forms cannot not use it.  Only the original one.
0
PatHartmanCommented:
That would make this a 1-1 relationship.  Those are extremely rare in the wild and would not be implemented using a combo.  The combo implies 1-many.  But, you have accepted an answer so whether I understand what you are doing or not is immaterial.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.