K
kim
Hi,
I have this code:
Private Sub Combo41_NotInList(NewData As String, Response
As Integer)
On Error GoTo Err_Damage_NotInList
Dim strMsg As String
strMsg = "Item is not in list. Add it?"
' Prompt user to verify they wish to add new value
If MsgBox(strMsg, vbOKCancel) = vbOK Then
' Open your form to add new entry
DoCmd.OpenForm "frmDamage", acFormDS, , , acFormAdd,
acDialog
' You can add NewData as OpenArgs in the line
' above to pass to new entry to opening form
' Set Response argument to indicate that data is being
added
Response = acDataErrAdded
Else
' If user chooses Cancel, suppress error message
Response = acDataErrContinue
End If
Exit_Damage_NotInList:
Exit Sub
Err_Damage_NotInList:
MsgBox Err.Description
Resume Exit_Damage_NotInList
End Sub
But for some reason when i try to add a new item to the
list access gives me the error message: The text you
entered isn't an item on the list. Select an item from
the list, or enter text that matches one of the listed
item.
Even when i select one from the list it just gives me the
same message again.
What I'm trying to accomplish is when a user opens the
frmCustomer there is a sub form frmDamageSub. The
combobox should let them either choose an existing item or
enter a new item, but not let them enter any duplicates.
Is this possible? I'm new at access, so any help would be
appreciated.
I have this code:
Private Sub Combo41_NotInList(NewData As String, Response
As Integer)
On Error GoTo Err_Damage_NotInList
Dim strMsg As String
strMsg = "Item is not in list. Add it?"
' Prompt user to verify they wish to add new value
If MsgBox(strMsg, vbOKCancel) = vbOK Then
' Open your form to add new entry
DoCmd.OpenForm "frmDamage", acFormDS, , , acFormAdd,
acDialog
' You can add NewData as OpenArgs in the line
' above to pass to new entry to opening form
' Set Response argument to indicate that data is being
added
Response = acDataErrAdded
Else
' If user chooses Cancel, suppress error message
Response = acDataErrContinue
End If
Exit_Damage_NotInList:
Exit Sub
Err_Damage_NotInList:
MsgBox Err.Description
Resume Exit_Damage_NotInList
End Sub
But for some reason when i try to add a new item to the
list access gives me the error message: The text you
entered isn't an item on the list. Select an item from
the list, or enter text that matches one of the listed
item.
Even when i select one from the list it just gives me the
same message again.
What I'm trying to accomplish is when a user opens the
frmCustomer there is a sub form frmDamageSub. The
combobox should let them either choose an existing item or
enter a new item, but not let them enter any duplicates.
Is this possible? I'm new at access, so any help would be
appreciated.