473,324 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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
Dec 20 '06 #1
2 1142
On Wed, 20 Dec 2006 03:17:39 -0500, "luanhoxung"
<lu********@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.

>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
Dec 20 '06 #2
thanks alot, Tom !
I will try doing ur advise.

thanks again.

Dec 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesn¹t matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
10
by: AZRebelCowgirl73 | last post by:
This is what I have so far: My program! import java.util.*; import java.lang.*; import java.io.*; import ch06.lists.*; public class UIandDB {
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
12
by: kalyan | last post by:
Hi, I am using Linux + SysV Shared memory (sorry, but my question is all about offset + pointers and not about linux/IPC) and hence use offset's instead on pointers to store the linked list in...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.