All, using access 2003. I have created an update form for a mgr to update tables used as combo boxes on data entry form. Five of the comb boxes have an autonumber id field, main field and description field. I have code to add one field to the combo box and it is working.
Code:
Private Sub cboAcctCodes_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Employee...")
If i = vbYes Then
strSQL = "Insert Into tbl_ACCOUNTINGCODES ([TXT_ACCOUNTINGCODE]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else: Response = acDataErrContinue
End If
End Sub
But I want to also have the mgr be able to add the description field. I found code to add multiple fields to a combo box but I don't know how to make it work for my situation. I have been trying to replace my values but keep getting all kinds of errors. Here is the original code without my modifications:
Code:
Private Sub MovieGenre_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
Dim NewGenreID As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
' Create a New Genre ID (MovieGenre) from the data entered
' by taking the first three characters of the string
' converting to uppercase to store in the table
NewGenreID = UCase(Trim(Left(NewData, 3)))
Msg = "'" & NewData & "' is not currently in the list of Genres." & vbCr & vbCr
Msg = Msg & "Do you want create a new genre record?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Movie Genre...")
If i = vbYes Then
strSQL = "Insert Into MovieGenre ([MovieGenre],[MovieGenreDescription]) values ('" & NewGenreID & "','" & NewData & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
It looks like it would add the main field and description like I want for my situation but it looks like it also adds the id field whick I already have in my autonumber.
Can anyone help modify my first code with this. Thanks