Coding a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a little help coding a combo box. I think I need code for the "not in
list" event to bring up a message box that says " The referral source you
have netered is not in the list. Would you like to add this referral
source?" There should be a "yes" and "no" button. If ys is selected, I need
to open a subform called frm_AddRefSource. I would like the text that was
originally entered to appear in the subform in the field named [Company].

Any suggestions would be much appreciated. Thanks!
 
This is the coding that I have used to add a value to a list when the "not
in the list" condition occurs.

Port is a 3 letter location for a town i.e. LAX is the IATA code for Los
Angeles Airport, LHR is Heathrow in England

If a port code is not in the list, a message is displayed if the user
selects Yes the the item is added to list. I do not use a subform to add the
item.

Private Sub select_port_NotInList(NewData As String, Response As Integer)

Dim strmsg As String
Dim rsy As DAO.Recordset
Dim db As DAO.Database

strmsg = "'" & UCase$(NewData) & "' is not in the list. "
strmsg = strmsg & "Would you like to add this Port ? "

If vbNo = MsgBox(strmsg, vbYesNo + vbQuestion, " New Port Code") Then
resposne = acDataErrDisplay
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("tbl_cities")
rst.AddNew
rst("city_code") = UCase$(NewData)
rst.Update
Response = acDataErrAdded
End If

End Sub
 
Back
Top