hi all !
On my form, i have a combo box with using NotInList even.
My combo box name Port. It is got from Table Port which have 2 fields:
Port & Country
i can add new Port from my combo box, but my goal is add new Port with
Country. i tried more and more but not succeed.
Pls give me a hand or any example code are appreciated.
Thanks for ur time.
here my code:
Private Sub PORT_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' hasnot in OurPort" & vbCrLf & vbCrLf
strMsg = strMsg & vbCrLf & vbCrLf & "Do u want to add it?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("TPORT", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Port = NewData
rs.Update
If Err Then
MsgBox "An error occured. Please try again."
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub