xena_morph
08-11-2000, 09:38 AM
i have a combo box on a form the info from which comes form one table and the records created on this form are placed in another table.
Is it possible to make any additions typed in this combobox add to the first table as well as being recorded in the second table?
is so can someone please tell me?
D B Lawson
08-12-2000, 01:11 PM
If you want to add to the combo box, in the controls NotOnList Event have the following msg:
Private Sub ComboBoxName_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Then, on the DblClick Event:
Private Sub Combo50_DblClick(Cancel As Integer)
On Error GoTo Err_Combo50_DblClick
Dim lngCombo50 As Long
If IsNull(Me![Combo50]) Then
Me![Combo50].Text = ""
Else
lngCombo50 = Me![Combo50]
Me![Combo50] = Null
End If
DoCmd.OpenForm "FrmCountry", , , , , acDialog, "GotoNew"
Me![Combo50].Requery
If lngCombo50 <> 0 Then Me![Combo50] = lngCombo50
Exit_Combo50_DblClick:
Exit Sub
Err_Combo50_DblClick:
MsgBox Err.Description
Resume Exit_Combo50_DblClick
End Sub
Have a form which would open based on the table that the combo box gets its info from.
Obviously, replace Combo50 and FrmCountry for the appropriate names.
So, if you try to select something which is not on the list, you get the error message. Click OK then double click the combo box to open a form in add mode. Enter the new entry and return to the main form. Select the new entry from the combo box.
Hope this is what you wanted and it makes sense.