473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not In List Error

Hi,

I have a form Form1 that displays surveys. This form has a subform1
which displays questions related to a particular survey. This subform
has a subsubform which displays subquestions for a particular question
for a particular survey.
I have created a combo box for questions on subform1. What I am trying
to achieve is if a user wants to add a question to a particular survey,
if the question is not in the list, the user should be able to add the
new question in the underlying lookup table and at the same time save
the record on the form (associating this new question to the Survey).
This is the code I have written;

Private Sub cboQuestion_Not InList(NewData As String, Response As
Integer)

Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Question...")
If i = vbYes Then
strSQL = "Insert Into LkupQuestions ([Question]) values ('" &
NewData & "')"
CurrentDb.Execu te strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContin ue
End If
End Sub

Each time I try to add a new question to the list I get an error: The
text you have entered is not in list, select the text from the list
box. . . . . .

Please let me know what I am doing wrong as I want to acheive the same
results with the subsubform by adding a new subquestion and associating
it with question and survey.

Any help would be appreciated.
Thanks

Kaur

Mar 6 '06 #1
2 1709
Sounds like you just have to requery the combo box after your insert
statement.

If you're not even getting to this point you may have fallen into the Access
trap. Did you start to write the procedure in the code window by selecting
the control on the left and the procedure on the right? Doing it this way
sometimes does not bind the event to the control. Check the properties
window of the control in design view to make sure there is [Event Procedure]
there.
"Kaur" <ka***@saic.com > wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hi,

I have a form Form1 that displays surveys. This form has a subform1
which displays questions related to a particular survey. This subform
has a subsubform which displays subquestions for a particular question
for a particular survey.
I have created a combo box for questions on subform1. What I am trying
to achieve is if a user wants to add a question to a particular survey,
if the question is not in the list, the user should be able to add the
new question in the underlying lookup table and at the same time save
the record on the form (associating this new question to the Survey).
This is the code I have written;

Private Sub cboQuestion_Not InList(NewData As String, Response As
Integer)

Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Question...")
If i = vbYes Then
strSQL = "Insert Into LkupQuestions ([Question]) values ('" &
NewData & "')"
CurrentDb.Execu te strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContin ue
End If
End Sub

Each time I try to add a new question to the list I get an error: The
text you have entered is not in list, select the text from the list
box. . . . . .

Please let me know what I am doing wrong as I want to acheive the same
results with the subsubform by adding a new subquestion and associating
it with question and survey.

Any help would be appreciated.
Thanks

Kaur

Mar 6 '06 #2
Thanks ever so much. I found the mistake. the code runs without any
problem

Mar 7 '06 #3

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

Similar topics

2
2389
by: Alexander Malkis | last post by:
//Consider: class A { /*...*/ }; template<class T> class list {/*... */ }; void f(const list<const A*> lst) { /*...doesn't change the arg...*/ } void g(list<A*> lst) { f(lst); //Intuitively ok, but compiler rejects. }
4
11936
by: 3rdshiftcoder | last post by:
Hi- I'd like to use this class from a book but am getting a compiler error. On the line private List < String > list; p.932 Chapter 19 found in the code below in the eclipse editor it is underlined in red. It is saying it is a syntax error and to delete the tokens. I'd like to use the code below in my program i am working on for my hobby. It will make life so much easier when i get past the compiler error.
19
3534
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main form, the subform returns the records based on the two criteria. The criteria used on the main form are values selected in two list boxes. When the user clicks on the first list box (lstCollege), it returns values in the second list box...
7
2158
by: dam_fool_2003 | last post by:
friends, I wanted to learn the various ways of inserting a single list. so: Method 1: #include<stdlib.h> #include<stdio.h> struct node { unsigned int data; struct node *next;
24
5755
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 macros */ #ifndef PUBLIC #define PUBLIC
6
4592
by: Steve Lambert | last post by:
Hi, I've knocked up a number of small routines to create and manipulate a linked list of any structure. If anyone could take a look at this code and give me their opinion and details of any potential pitfalls I'd be extremely grateful. Cheers Steve
8
4957
by: Vivek | last post by:
Hi, I wish to update the LIST<T> created in PARENT FORM from the CHILD FORM. Currently I have declared the LIST<Role> as public in my parent form. What can I do to update the <LIST>? Thanks
4
1970
by: Avon | last post by:
Hello there. I have a problem with text files in C. Basically what I do is, let the user save the data from a singly-linked list, in to a .txt using this code: while (list!=NULL) { fprintf(fp,"%s %s %s %c %f %d\n",list->kodikos,list->perigrafi,list->etaireia,list->diathesimotita,list->timi,list->posotita); list=list->next; }
2
6228
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a Table/Query. Or it could be a value list, a static list of data. But what if your information is not held in a table, and it is not a static list. Examples I have used have been, “next 100 prime numbers after this one”, “Every third Friday from start of...
7
5764
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 compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template classes. One is List1, the other one is ListNode. The codes are below: // test-linked-list.cpp :...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.