G
Guest
My form contains a combo box cboAirline whose control source is tblAirline,
which has three fields:
pk_strAirlineCode text 3
strAirline text 25
strAirlineShort text 15
Column 1 is bound, the column widths are 0,0,1.
The combo box has a NotInList event procedure, as follows:
Private Sub cboAirline_NotInList(NewData As String, Response As Integer)
If MsgBox("This airline is not in the list. Add it?", vbOKCancel,
"Flight Detail") = vbOK Then
DoCmd.OpenForm "fdlgAirline", , , , , acDialog
If CurrentProject.AllForms("fdlgAirline").IsLoaded Then
cboAirline = Forms("fdlgAirline")!txt_pk_strAirlineCode
DoCmd.Close acForm, "fdlgAirline"
End If
Response = acDataErrAdded
Else
Me!cboAirline.Undo
Response = acDataErrContinue
End If
End Sub
The procedure is supposed to return the airline code from the dialog box to
the main form, but it triggers the NotInList error again, even though the new
item has been added to the drop-down list. I tried changing the return to
Forms("fdlgAirline")!txt_strAirlineShort, but this triggers an error
(appropriately) that the data is too long for the field.
Where have I gone wrong?
which has three fields:
pk_strAirlineCode text 3
strAirline text 25
strAirlineShort text 15
Column 1 is bound, the column widths are 0,0,1.
The combo box has a NotInList event procedure, as follows:
Private Sub cboAirline_NotInList(NewData As String, Response As Integer)
If MsgBox("This airline is not in the list. Add it?", vbOKCancel,
"Flight Detail") = vbOK Then
DoCmd.OpenForm "fdlgAirline", , , , , acDialog
If CurrentProject.AllForms("fdlgAirline").IsLoaded Then
cboAirline = Forms("fdlgAirline")!txt_pk_strAirlineCode
DoCmd.Close acForm, "fdlgAirline"
End If
Response = acDataErrAdded
Else
Me!cboAirline.Undo
Response = acDataErrContinue
End If
End Sub
The procedure is supposed to return the airline code from the dialog box to
the main form, but it triggers the NotInList error again, even though the new
item has been added to the drop-down list. I tried changing the return to
Forms("fdlgAirline")!txt_strAirlineShort, but this triggers an error
(appropriately) that the data is too long for the field.
Where have I gone wrong?