P
Pete
I have a combo box bound to a lookup table. It contains 3 columns. The first
column is an ID column and is zero width. I have used the Not In List event
to add values many times before without a problem, but for some reason I
still get the "text you entered is not in the list" error, even when a value
has been successfully added and can be seen in the list. I just can't see why
this is happening.
Private Sub cboiStockID_NotInList(NewData As String, Response As Integer)
Dim intAnswer As Integer
NewData = UpperCase(NewData)
intAnswer = MsgBox("Add " & NewData & " as a new Stock Code?",
vbQuestion + vbYesNo, Me.Caption)
If intAnswer = vbYes Then
Enter_Stock_Name:
Dim strStockName As String
strStockName = InputBox("Please enter the corresponding Stock Name
for " & NewData, "Setup New Stock Code")
If strStockName = "" Then
intAnswer = MsgBox("You must enter a value for this Stock Name.
Click OK to continue or Cancel to abort.", vbExclamation + vbOKCancel, "Stock
Name Error")
If intAnswer = vbOK Then
GoTo Enter_Stock_Name
Else
GoTo Exit_Sub
End If
End If
Dim strSQL As String
strSQL = "INSERT INTO tlkpStock (cStockCode, cStockName) SELECT '" &
NewData & "', '" & strStockName & "'"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Exit Sub
End If
Exit_Sub:
Response = acDataErrDisplay
End Sub
column is an ID column and is zero width. I have used the Not In List event
to add values many times before without a problem, but for some reason I
still get the "text you entered is not in the list" error, even when a value
has been successfully added and can be seen in the list. I just can't see why
this is happening.
Private Sub cboiStockID_NotInList(NewData As String, Response As Integer)
Dim intAnswer As Integer
NewData = UpperCase(NewData)
intAnswer = MsgBox("Add " & NewData & " as a new Stock Code?",
vbQuestion + vbYesNo, Me.Caption)
If intAnswer = vbYes Then
Enter_Stock_Name:
Dim strStockName As String
strStockName = InputBox("Please enter the corresponding Stock Name
for " & NewData, "Setup New Stock Code")
If strStockName = "" Then
intAnswer = MsgBox("You must enter a value for this Stock Name.
Click OK to continue or Cancel to abort.", vbExclamation + vbOKCancel, "Stock
Name Error")
If intAnswer = vbOK Then
GoTo Enter_Stock_Name
Else
GoTo Exit_Sub
End If
End If
Dim strSQL As String
strSQL = "INSERT INTO tlkpStock (cStockCode, cStockName) SELECT '" &
NewData & "', '" & strStockName & "'"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Exit Sub
End If
Exit_Sub:
Response = acDataErrDisplay
End Sub