On Wed, 20 Dec 2006 03:17:39 -0500, "luanhoxung"
<luanhoxung@yahoo.comwrote:
The best way is to pop up a form to ask for both fields. Open that
form with acDialog in the DoCmd.OpenForm call so it becomes a modal
dialog.
The poor man's version would be to use an Input Box:
rs.AddNew
rs!Port = NewData
rs!Country = InputBox("What country is this port in?")
rs.Update
-Tom.
Quote:
>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
>
|