473,395 Members | 1,535 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,395 software developers and data experts.

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_NotInList(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.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
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 1701
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.googlegr oups.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_NotInList(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.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
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
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);...
4
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...
19
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...
7
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
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...
6
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...
8
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
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) {...
2
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.