combobox

  • Thread starter Thread starter kim
  • Start date Start date
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.
 
Hi Kim,
it maybe that in creating the combobox there was a little
confusion regarding control source the control is bound to
and row source visible columns.

That is, the control source of a combobox is the linking
field between the form's recordsource table and the
combobox rowsource lookup/reference table.

Linking fields are usually numeric. Whereas users
typically like to work with text values.

What sometimes happens when setting up a combobox only the
text value fields are included in the design. If this is
the cause, then include the linking key field as the first
column with a width of 0cm/0" so that it is not visible.

Luck
Jonathan
 
Back
Top