I am trying to use Allen Brownes code for adding a value to a combo, but am having some difficulty.
The problem I am having is the field [JobID] is required. I tried adding the update portion into it, but then get a syntax error on the INSERT statement. What am I messing up?
Microsoft Access tips: Adding items to a combo/list box
Techniques for adding items to drop-down boxes in Microsoft Access
allenbrowne.com
Code:
Private Sub TypeID_NotInList(NewData As String, Response As Integer)
Dim strtmp As String
strtmp = "Add '" & NewData & "' as a new type?"
If MsgBox(strtmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
strtmp = "INSERT INTO tblFixtureTypes ( TypeName )"
strtmp = strtmp & "UPDATE tblFixtureTypes SET tblFixtureTypes.JobID = [Forms]![JobQuote]![JobID]"
strtmp = strtmp & "SELECT """ & NewData & """ AS TypeName;"
DBEngine(0)(0).Execute strtmp, dbFailOnError
Response = acDataErrAdded
End If
End Sub
The problem I am having is the field [JobID] is required. I tried adding the update portion into it, but then get a syntax error on the INSERT statement. What am I messing up?