Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 20th, 2006, 08:25 AM
luanhoxung
Guest
 
Posts: n/a
Default Not In list problem !

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


  #2  
Old December 20th, 2006, 02:05 PM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: Not In list problem !

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
>
  #3  
Old December 20th, 2006, 03:35 PM
luanhoxung
Guest
 
Posts: n/a
Default Re: Not In list problem !

thanks alot, Tom !
I will try doing ur advise.

thanks again.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles